code: def truncate_target(
      dataset: Dataset, prediction_length: int, lead_time: int = 0
  ):
      def _truncate(data: DataEntry):
          data = data.copy()
          target = data["target"]
          assert (
              target.shape[-1] >= prediction_length
          )  # handles multivariate case (target_dim, history_length)
          data["target"] = target[..., : -prediction_length - lead_time]
          return data
  
      return map(_truncate, dataset)
  
file_path: gluonts/src/gluonts/nursery/temporal_hierarchical_forecasting/utils/gluonts_helper.py
imports: from typing import Dict
  import numpy
  import pandas
  from gluonts.dataset.common import DataEntry, Dataset
  from gluonts.dataset.field_names import FieldName
label_desc: Use image node_id 2 for calling a global function with example usage: truncate_target(dataset, prediction_length, lead_time) and returns: map, data