code: def mape(
      y: np.ndarray,
      y_hat: np.ndarray,
      weights: Optional[np.ndarray] = None,
      axis: Optional[int] = None,
  ) -> Union[float, np.ndarray]:
      """Mean Absolute Percentage Error
  
      Calculates Mean Absolute Percentage Error  between
      `y` and `y_hat`. MAPE measures the relative prediction
      accuracy of a forecasting method by calculating the percentual deviation
      of the prediction and the observed value at a given time and
      averages these devations over the length of the series.
      The closer to zero an observed value is, the higher penalty MAPE loss
      assigns to the corresponding error.
  
      $$ \mathrm{MAPE}(\\mathbf{y}_{\\tau}, \\mathbf{\hat{y}}_{\\tau}) = \\frac{1}{H} \\sum^{t+H}_{\\tau=t+1} \\frac{|y_{\\tau}-\hat{y}_{\\tau}|}{|y_{\\tau}|} $$
  
      **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>
      `mape`: numpy array, (single value).
      """
      _metric_protections(y, y_hat, weights)
  
      delta_y = np.abs(y - y_hat)
      scale = np.abs(y)
      mape = _divide_no_nan(delta_y, scale)
      mape = np.average(mape, weights=weights, axis=axis)
  
      return mape
  
file_path: neuralforecast/neuralforecast/losses/numpy.py
imports: from typing import Optional, Union
  import numpy
label_desc: Use image node_id 6 for calling a global function with example usage: mape(y, y_hat, weights, axis) and returns: mape