code: def mase(
      y: np.ndarray,
      y_hat: np.ndarray,
      y_train: np.ndarray,
      seasonality: int,
      weights: Optional[np.ndarray] = None,
      axis: Optional[int] = None,
  ) -> Union[float, np.ndarray]:
      """Mean Absolute Scaled Error
      Calculates the Mean Absolute Scaled Error between
      `y` and `y_hat`. MASE measures the relative prediction
      accuracy of a forecasting method by comparinng the mean absolute errors
      of the prediction and the observed value against the mean
      absolute errors of the seasonal naive model.
      The MASE partially composed the Overall Weighted Average (OWA),
      used in the M4 Competition.
  
      $$ \mathrm{MASE}(\\mathbf{y}_{\\tau}, \\mathbf{\hat{y}}_{\\tau}, \\mathbf{\hat{y}}^{season}_{\\tau}) = \\frac{1}{H} \sum^{t+H}_{\\tau=t+1} \\frac{|y_{\\tau}-\hat{y}_{\\tau}|}{\mathrm{MAE}(\\mathbf{y}_{\\tau}, \\mathbf{\hat{y}}^{season}_{\\tau})} $$
  
      **Parameters:**<br>
      `y`: numpy array, (batch_size, output_size), Actual values.<br>
      `y_hat`: numpy array, (batch_size, output_size)), Predicted values.<br>
      `y_insample`: numpy array, (batch_size, input_size), Actual insample Seasonal Naive predictions.<br>
      `seasonality`: int. Main frequency of the time series; Hourly 24,  Daily 7, Weekly 52, Monthly 12, Quarterly 4, Yearly 1.
      `mask`: numpy array, Specifies date stamps per serie to consider in loss.<br>
  
      **Returns:**<br>
      `mase`: numpy array, (single value).
  
      **References:**<br>
      [Rob J. Hyndman, & Koehler, A. B. "Another look at measures of forecast accuracy".](https://www.sciencedirect.com/science/article/pii/S0169207006000239)<br>
      [Spyros Makridakis, Evangelos Spiliotis, Vassilios Assimakopoulos, "The M4 Competition: 100,000 time series and 61 forecasting methods".](https://www.sciencedirect.com/science/article/pii/S0169207019301128)
      """
      delta_y = np.abs(y - y_hat)
      delta_y = np.average(delta_y, weights=weights, axis=axis)
  
      scale = np.abs(y_train[:-seasonality] - y_train[seasonality:])
      scale = np.average(scale, axis=axis)
  
      mase = delta_y / scale
  
      return mase
  
file_path: neuralforecast/neuralforecast/losses/numpy.py
imports: from typing import Optional, Union
  import numpy
label_desc: Use image node_id 8 for calling a global function with example usage: mase(y, y_hat, y_train, seasonality, weights, axis) and returns: mase