code: def materialize_dataset(
      dataset_name: str,
      path: Path = default_dataset_path,
      regenerate: bool = False,
      dataset_writer: DatasetWriter = default_dataset_writer,
      prediction_length: Optional[int] = None,
  ) -> Path:
      """
      Ensures that the dataset is materialized under the `path / dataset_name`
      path.
  
      Parameters
      ----------
      dataset_name
          Name of the dataset, for instance "m4_hourly".
      regenerate
          Whether to regenerate the dataset even if a local file is present.
          If this flag is False and the file is present, the dataset will not
          be downloaded again.
      path
          Where the dataset should be saved.
      prediction_length
          The prediction length to be used for the dataset. If None, the default
          prediction length will be used. The prediction length might not be
          available for all datasets.
  
      Returns
      -------
          The path where the dataset is materialized
      """
      assert dataset_name in dataset_recipes.keys(), (
          f"{dataset_name} is not present, please choose one from "
          f"{sorted(dataset_recipes)}."
      )
  
      path.mkdir(parents=True, exist_ok=True)
      dataset_path = path / dataset_name
  
      dataset_recipe = dataset_recipes[dataset_name]
  
      if not dataset_path.exists() or regenerate:
          logging.info(f"downloading and processing {dataset_name}")
          if dataset_path.exists():
              # If regenerating, we need to remove the directory contents
              shutil.rmtree(dataset_path)
              dataset_path.mkdir()
  
          # Optionally pass prediction length to not override any non-None
          # defaults (e.g. for M4)
          kwargs: Dict[str, Any] = {"dataset_path": dataset_path}
          if prediction_length is not None:
              kwargs["prediction_length"] = prediction_length
          kwargs["dataset_writer"] = dataset_writer
          dataset_recipe(**kwargs)
      else:
          logging.info(
              f"using dataset already processed in path {dataset_path}."
          )
  
      return dataset_path
  
imports: import logging
  import shutil
  from functools import partial
  from pathlib import Path
  from typing import Any, Dict, Optional
  from gluonts.dataset import DatasetWriter
  from gluonts.dataset.artificial import ConstantDataset
  from gluonts.dataset.common import TrainDatasets, load_datasets
  from gluonts.dataset.jsonl import JsonLinesWriter
  from ._artificial import generate_artificial_dataset
  from ._airpassengers import generate_airpassengers_dataset
  from ._gp_copula_2019 import generate_gp_copula_dataset
  from ._lstnet import generate_lstnet_dataset
  from ._m3 import generate_m3_dataset
  from ._m4 import generate_m4_dataset
  from ._m5 import generate_m5_dataset
  from ._tsf_datasets import generate_forecasting_dataset
  from ._uber_tlc import generate_uber_dataset
label_desc: Use image node_id 2 for calling a global function with example usage: materialize_dataset(dataset_name, path, regenerate, dataset_writer, prediction_length) and returns: dataset_path