code: def mse(test, ref, mask=None):
      
  
      test, ref, mask = _preprocess_input(test, ref, mask)
  
      if mask is not None:
          test = mask * test
          ref = mask * ref
  
      return np.mean(np.square(test - ref))
docs: Mean Squared Error (MSE)
  
      Calculate the MSE between a test image and a reference image.
  
      Parameters
      ----------
      ref : np.ndarray
          the reference image
      test : np.ndarray
          the tested image
      mask : np.ndarray, optional
          the mask for the ROI
  
      Notes
      -----
      Compute the metric only on magnetude.
  
      1/N * |ref - test|_2
  
      Returns
      -------
      mse: float, the mse