code: def mse(
      y: np.ndarray,
      y_hat: np.ndarray,
      weights: Optional[np.ndarray] = None,
      axis: Optional[int] = None,
  ) -> Union[float, np.ndarray]:
      """Mean Squared Error
  
      Calculates Mean Squared Error between
      `y` and `y_hat`. MSE measures the relative prediction
      accuracy of a forecasting method by calculating the
      squared deviation of the prediction and the true
      value at a given time, and averages these devations
      over the length of the series.
  
      $$ \mathrm{MSE}(\\mathbf{y}_{\\tau}, \\mathbf{\hat{y}}_{\\tau}) = \\frac{1}{H} \\sum^{t+H}_{\\tau=t+1} (y_{\\tau} - \hat{y}_{\\tau})^{2} $$
  
      **Parameters:**<br>
      `y`: numpy array, Actual values.<br>
      `y_hat`: numpy array, Predicted values.<br>
      `mask`: numpy array, Specifies date stamps per serie to consider in loss.<br>
  
      **Returns:**<br>
      `mse`: numpy array, (single value).
      """
      _metric_protections(y, y_hat, weights)
  
      delta_y = np.square(y - y_hat)
      if weights is not None:
          mse = np.average(
              delta_y[~np.isnan(delta_y)],
              weights=weights[~np.isnan(delta_y)],
              axis=axis,
          )
      else:
          mse = np.nanmean(delta_y, axis=axis)
  
      return mse
  
file_path: neuralforecast/neuralforecast/losses/numpy.py
imports: from typing import Optional, Union
  import numpy
label_desc: Use image node_id 4 for calling a global function with example usage: mse(y, y_hat, weights, axis) and returns: mse