code: def evaluate_forecasts(
      forecasts: Iterable[Forecast],
      *,
      test_data: TestData,
      metrics,
      axis: Optional[Union[int, tuple]] = None,
      batch_size: int = 100,
      mask_invalid_label: bool = True,
      allow_nan_forecast: bool = False,
      seasonality: Optional[int] = None,
  ) -> pd.DataFrame:
      """
      Evaluate ``forecasts`` by comparing them with ``test_data``, according
      to ``metrics``.
  
      .. note:: This feature is experimental and may be subject to changes.
  
      The optional ``axis`` arguments controls aggregation of the metrics:
      - ``None`` (default) aggregates across all dimensions
      - ``0`` aggregates across the dataset
      - ``1`` aggregates across the first data dimension (time, in the univariate setting)
      - ``2`` aggregates across the second data dimension (time, in the multivariate setting)
  
      Return results as a Pandas ``DataFrame``.
      """
      metrics_values = evaluate_forecasts_raw(
          forecasts=forecasts,
          test_data=test_data,
          metrics=metrics,
          axis=axis,
          batch_size=batch_size,
          mask_invalid_label=mask_invalid_label,
          allow_nan_forecast=allow_nan_forecast,
          seasonality=seasonality,
      )
      index0 = metrics_values.pop("__index_0", None)
  
      metric_shape = metrics_values[first(metrics_values)].shape
      if metric_shape == ():
          index = [None]
      else:
          index_arrays = np.unravel_index(
              range(prod(metric_shape)), metric_shape
          )
          if index0 is not None:
              index0_repeated = np.take(
                  index0, indices=index_arrays[0], axis=0
              )
              index_arrays = (*zip(*index0_repeated), *index_arrays[1:])  # type: ignore
          index = pd.MultiIndex.from_arrays(index_arrays)
  
      flattened_metrics = valmap(np.ravel, metrics_values)
  
      return pd.DataFrame(flattened_metrics, index=index)
  
imports: import logging
  from collections import ChainMap
  from typing import Iterable, List, Optional, Union
  from dataclasses import dataclass
  from toolz import first, valmap
  import numpy
  import pandas
  from tqdm import tqdm
  from gluonts.dataset import DataEntry
  from gluonts.dataset.split import TestData
  from gluonts.ev.ts_stats import seasonal_error
  from gluonts.itertools import batcher, prod
  from gluonts.model import Forecast, Predictor
  from gluonts.time_feature.seasonality import get_seasonality
label_desc: Use image node_id 3 for calling a global function with example usage: evaluate_forecasts(forecasts) and returns: pd