code: def convert_data(
      data: List[Dict],
      train_offset: int,
      default_start_timestamp: Optional[str] = None,
  ):
      train_data = []
      test_data = []
      for i, data_entry in tqdm(
          enumerate(data), total=len(data), desc="creating json files"
      ):
          # Convert the data to a GluonTS dataset...
          # - `default_start_timestamp` is required for some datasets which
          #   are not listed here since some datasets do not define start
          #   timestamps
          # - `item_id` is added for all datasets ... many datasets provide
          #   the "series_name"
          test_data.append(
              {
                  "target": data_entry["target"],
                  "start": str(
                      data_entry.get(
                          "start_timestamp", default_start_timestamp
                      )
                  ),
                  "item_id": data_entry.get("series_name", i),
                  "feat_static_cat": [i],
              }
          )
  
          train_data.append(
              {
                  "target": data_entry["target"][:-train_offset],
                  "start": str(
                      data_entry.get(
                          "start_timestamp", default_start_timestamp
                      )
                  ),
                  "item_id": data_entry.get("series_name", i),
                  "feat_static_cat": [i],
              }
          )
  
      return train_data, test_data
  
file_path: gluonts/src/gluonts/dataset/repository/_tsf_datasets.py
imports: from pathlib import Path
  from tempfile import TemporaryDirectory
  from typing import Dict, List, NamedTuple, Optional
  from urllib import request
  from zipfile import ZipFile
  from pandas.tseries.frequencies import to_offset
  from gluonts.dataset import DatasetWriter
  from gluonts.dataset.common import MetaData, TrainDatasets
  from gluonts.dataset.field_names import FieldName
  from gluonts.gluonts_tqdm import tqdm
  from ._tsf_reader import TSFReader, frequency_converter
  from ._util import metadata, request_retrieve_hook
label_desc: Use image node_id 1 for calling a global function with example usage: convert_data(data, train_offset, default_start_timestamp) and returns: train_data,  test_data