def MSD(Z, Y):
    """Compute the mean square distortion (MSD) between Z and Y

    Parameters
    ----------
    Z: torch.Tensor of shape (n_samples, n_features)
       Tensor to be compared

    Y: torch.Tensor of shape (n_samples, n_features)
       Tensor to be compared

    Returns
    -------
    msd: float
         Mean square distance between Z and Y
    """
    msd = ((Z - Y) ** 2).sum()
    msd /= Z.shape[0]
    return msd