code: def mean_weighted_quantile_loss(
      y_pred: np.ndarray, y_true: np.ndarray, quantiles: List[str]
  ) -> float:
      y_true_rep = y_true[:, None].repeat(len(quantiles), axis=1)
      quantiles = np.array([float(q) for q in quantiles])
      quantile_losses = 2 * np.sum(
          np.abs(
              (y_pred - y_true_rep)
              * ((y_true_rep <= y_pred) - quantiles[:, None])
          ),
          axis=-1,
      )  # shape [num_time_series, num_quantiles]
      denom = np.sum(np.abs(y_true))  # shape [1]
      weighted_losses = (
          quantile_losses.sum(0) / denom
      )  # shape [num_quantiles]
      return weighted_losses.mean()
  
file_path: gluonts/src/gluonts/nursery/few_shot_prediction/src/meta/metrics/numpy.py
imports: import math
  import numpy
  import numpy.ma
  from typing import List, Dict
  from meta.datasets.splits import EvaluationDataset
label_desc: Use image node_id 8 for calling a global function with example usage: mean_weighted_quantile_loss(y_pred, y_true, quantiles) and returns: weighted_losses