code: def quantile_loss(
      y: np.ndarray,
      y_hat: np.ndarray,
      q: float = 0.5,
      weights: Optional[np.ndarray] = None,
      axis: Optional[int] = None,
  ) -> Union[float, np.ndarray]:
      """Quantile Loss
  
      Computes the quantile loss between `y` and `y_hat`.
      QL measures the deviation of a quantile forecast.
      By weighting the absolute deviation in a non symmetric way, the
      loss pays more attention to under or over estimation.
      A common value for q is 0.5 for the deviation from the median (Pinball loss).
  
      $$ \mathrm{QL}(\\mathbf{y}_{\\tau}, \\mathbf{\hat{y}}^{(q)}_{\\tau}) = \\frac{1}{H} \\sum^{t+H}_{\\tau=t+1} \Big( (1-q)\,( \hat{y}^{(q)}_{\\tau} - y_{\\tau} )_{+} + q\,( y_{\\tau} - \hat{y}^{(q)}_{\\tau} )_{+} \Big) $$
  
      **Parameters:**<br>
      `y`: numpy array, Actual values.<br>
      `y_hat`: numpy array, Predicted values.<br>
      `q`: float, between 0 and 1. The slope of the quantile loss, in the context of quantile regression, the q determines the conditional quantile level.<br>
      `mask`: numpy array, Specifies date stamps per serie to consider in loss.<br>
  
      **Returns:**<br>
      `quantile_loss`: numpy array, (single value).
  
      **References:**<br>
      [Roger Koenker and Gilbert Bassett, Jr., "Regression Quantiles".](https://www.jstor.org/stable/1913643)
      """
      _metric_protections(y, y_hat, weights)
  
      delta_y = y - y_hat
      loss = np.maximum(q * delta_y, (q - 1) * delta_y)
  
      if weights is not None:
          quantile_loss = np.average(
              loss[~np.isnan(loss)],
              weights=weights[~np.isnan(loss)],
              axis=axis,
          )
      else:
          quantile_loss = np.nanmean(loss, axis=axis)
  
      return quantile_loss
  
file_path: neuralforecast/neuralforecast/losses/numpy.py
imports: from typing import Optional, Union
  import numpy
label_desc: Use image node_id 10 for calling a global function with example usage: quantile_loss(y, y_hat, q, weights, axis) and returns: quantile_loss