code: def _get_data_batch(
      input_batch: List[DataEntry],
      label_batch: List[DataEntry],
      forecast_batch: List[Forecast],
      seasonality: Optional[int] = None,
      mask_invalid_label: bool = True,
      allow_nan_forecast: bool = False,
  ) -> ChainMap:
      label_target = np.stack(
          [label["target"] for label in label_batch], axis=0
      )
      if mask_invalid_label:
          label_target = np.ma.masked_invalid(label_target)
  
      other_data = {
          "label": label_target,
      }
  
      seasonal_error_values = []
      for input_ in input_batch:
          seasonality_entry = seasonality
          if seasonality_entry is None:
              seasonality_entry = get_seasonality(
                  input_["start"].freqstr
              )
          input_target = input_["target"]
          if mask_invalid_label:
              input_target = np.ma.masked_invalid(input_target)
          seasonal_error_values.append(
              seasonal_error(
                  input_target,
                  seasonality=seasonality_entry,
                  time_axis=-1,
              )
          )
      other_data["seasonal_error"] = np.array(seasonal_error_values)
  
      return ChainMap(
          other_data, BatchForecast(forecast_batch, allow_nan=allow_nan_forecast)  # type: ignore
      )
  
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 1 for calling a global function with example usage: _get_data_batch(input_batch, label_batch, forecast_batch, seasonality, mask_invalid_label, allow_nan_forecast) and returns: ChainMap