class_docstr: Synthetic data set generated by providing a recipe.
  
  A recipe is either a (non-deterministic) function
  
      f(length: int, global_state: dict) -> dict
  
  or list of (field, function) tuples of the form
  
      (field: str, f(data: dict, length: int, global_state: dict) -> dict)
  
  which is processed sequentially, with data initially set to {},
  and each entry updating data[field] to the output of the function
  call.
class_docstr_tok: ["Synthetic","data","set","generated","by","providing","a","recipe",".","A","recipe","is","either","a","(","non-deterministic",")","function","f","(","length",":","int",",","global_state",":","dict",")","-",">","dict","or","list","of","(","field",",","function",")","tuples","of","the","form","(","field",":","str",",","f","(","data",":","dict",",","length",":","int",",","global_state",":","dict",")","-",">","dict",")","which","is","processed","sequentially",",","with","data","initially","set","to","{","}",",","and","each","entry","updating","data","[","field","]","to","the","output","of","the","function","call","."]
code: def generate(self) -> TrainDatasets:
      metadata = self.metadata
      data_it = generate(
          length=self.max_train_length + self.prediction_length,
          recipe=self.recipe,
          start=self.data_start,
      )
      full_length_data = take_as_list(data_it, self.num_timeseries)
  
      test_data = [
          RecipeDataset.trim_ts_item_front(
              x,
              self.trim_length_fun(
                  x, train_length=self.max_train_length
              ),
          )
          for x in full_length_data
      ]
      train_data = [
          RecipeDataset.trim_ts_item_end(x, self.prediction_length)
          for x in test_data
      ]
      return TrainDatasets(
          metadata=metadata,
          train=ListDataset(train_data, metadata.freq),
          test=ListDataset(test_data, metadata.freq),
      )
  
imports: import math
  import random
  from abc import abstractmethod
  from typing import Callable, Dict, List, NamedTuple, Optional, Tuple, Union, cast
  import numpy
  import pandas
  from pandas.tseries.frequencies import to_offset
  from pandas.tseries.offsets import BaseOffset, Week
  from gluonts.dataset.artificial.recipe import BinaryHolidays, BinaryMarkovChain, Constant, ForEachCat, Lag, LinearTrend, RandomCat, RandomGaussian, Stack, generate, take_as_list
  from gluonts.dataset.common import BasicFeatureInfo, CategoricalFeatureInfo, DataEntry, Dataset, ListDataset, MetaData, TrainDatasets
  from gluonts.dataset.field_names import FieldName
  from gluonts.dataset.stat import DatasetStatistics, calculate_dataset_statistics
label_desc: Use image node_id 8 for calling the RecipeDataset obj's underlying member method code with example usage: obj.generate() and returns: TrainDatasets