import torch


def mse_loss( pred: torch.Tensor, data: torch.Tensor, mask: torch.Tensor ) -> torch.Tensor:
  """Mean squared error loss."""  
  x_mean = pred[:,:,0]
  y_mean = pred[:,:,1]
  x = data[:,:, 0] 
  y = data[:,:, 1]    
  results = torch.pow(x-x_mean, 2) + torch.pow(y-y_mean, 2)
  results = results*mask[:,:,0]
  return torch.sum(results)/torch.sum(mask[:,:,0])