code: def get_new_metrics(test_data, predictor, quantile_levels):
      quantiles = [Quantile.parse(q) for q in quantile_levels]
  
      item_metrics_to_evaluate = (
          (
              sum_absolute_label
              + SumAbsoluteError()
              + mean_absolute_label
              + MSE()
              + MASE()
              + MAPE()
              + SMAPE()
              + MSIS()
          )
          .add(
              *[
                  SumQuantileLoss(q=quantile.value)
                  for quantile in quantiles
              ]
          )
          .add(*[Coverage(q=quantile.value) for quantile in quantiles])
      )
  
      aggregated_metrics_to_evaluate = (
          RMSE()
          + NRMSE()
          + ND()
          + OWA()
          + MAECoverage([quantile.value for quantile in quantiles])
          + MeanSumQuantileLoss(
              [quantile.value for quantile in quantiles]
          )
          + MeanWeightedSumQuantileLoss(
              [quantile.value for quantile in quantiles]
          ).add(
              *[
                  WeightedSumQuantileLoss(q=quantile.value)
                  for quantile in quantiles
              ]
          )
      )
  
      # mask invalid values
      masked_dataset = []
      for data_entry in test_data.dataset:
          masked_entry = deepcopy(data_entry)
          masked_entry["target"] = np.ma.masked_invalid(
              data_entry["target"]
          )
          masked_dataset.append(masked_entry)
  
      masked_test_data = TestData(
          dataset=masked_dataset,
          splitter=test_data.splitter,
          prediction_length=test_data.prediction_length,
          windows=test_data.windows,
          distance=test_data.distance,
          max_history=test_data.max_history,
      )
  
      # evaluate
      data_batches = list(get_data_batches(predictor, masked_test_data))
      item_metrics = evaluate(
          item_metrics_to_evaluate, data_batches, axis=1
      )
      aggregated_metrics = evaluate(
          aggregated_metrics_to_evaluate, data_batches, axis=None
      )
  
      # rename metrics to match naming of old evaluation approach
      all_metrics = {
          "seasonal_error": np.ma.mean(
              np.stack(
                  [data["seasonal_error"] for data in data_batches]
              )
          ),
          "abs_target_mean": np.ma.mean(
              item_metrics["mean_absolute_label"]
          ),
          **{
              f"Coverage[{quantile}]": np.ma.mean(
                  item_metrics[f"coverage[{quantile.value}]"]
              )
              for quantile in quantiles
          },
          "abs_error": np.ma.sum(
              item_metrics["sum_absolute_error[0.5]"]
          ),
          "abs_target_sum": np.ma.sum(
              item_metrics["sum_absolute_label"]
          ),
          **{
              f"QuantileLoss[{quantile}]": np.ma.sum(
                  item_metrics[f"sum_quantile_loss[{quantile.value}]"]
              )
              for quantile in quantiles
          },
          **{
              f"wQuantileLoss[{quantile}]": np.ma.sum(
                  aggregated_metrics[
                      f"weighted_sum_quantile_loss[{quantile.value}]"
                  ]
              )
              for quantile in quantiles
          },
          "mean_absolute_QuantileLoss": aggregated_metrics[
              "mean_sum_quantile_loss"
          ],
          "mean_wQuantileLoss": aggregated_metrics[
              "mean_weighted_sum_quantile_loss"
          ],
          "MAE_Coverage": aggregated_metrics["MAE_coverage"],
      }
  
      for metric_name in [
          "MSE[mean]",
          "MASE[0.5]",
          "MAPE[0.5]",
          "sMAPE[0.5]",
          "MSIS",
      ]:
          all_metrics[metric_name.split("[")[0]] = np.ma.mean(
              item_metrics[metric_name]
          )
  
      for metric_name in [
          "RMSE[mean]",
          "NRMSE[mean]",
          "ND[0.5]",
          "OWA[0.5]",
      ]:
          all_metrics[metric_name.split("[")[0]] = aggregated_metrics[
              metric_name
          ]
  
      return all_metrics
  
imports: from copy import deepcopy
  from typing import ChainMap, Iterator, Optional, Union
  from dataclasses import dataclass
  import numpy
  from gluonts.dataset.repository import get_dataset
  from gluonts.dataset.split import TestData, split
  from gluonts.ext.naive_2 import naive_2
  from gluonts.time_feature.seasonality import get_seasonality
  from gluonts.model.forecast import Quantile, SampleForecast
  from gluonts.model.seasonal_naive import SeasonalNaivePredictor
  from gluonts.evaluation import Evaluator
  from gluonts.evaluation.backtest import make_evaluation_predictions
  from gluonts.ev import evaluate
  from gluonts.ev.ts_stats import seasonal_error
  from gluonts.ev.metrics import MAPE, MASE, MSE, MSIS, SMAPE, Coverage, SumAbsoluteError, SumQuantileLoss, mean_absolute_label, sum_absolute_label, ND, NRMSE, RMSE, MAECoverage, MeanSumQuantileLoss, MeanWeightedSumQuantileLoss, WeightedSumQuantileLoss, OWA
label_desc: Use image node_id 2 for calling a global function with example usage: get_new_metrics(test_data, predictor, quantile_levels) and returns: all_metrics