code: def create_transformation(self) -> Transformation:
      transforms = (
          [AsNumpyArray(field=FieldName.TARGET, expected_ndim=1)]
          + (
              [
                  AsNumpyArray(field=name, expected_ndim=1)
                  for name in self.static_cardinalities.keys()
              ]
          )
          + [
              AsNumpyArray(field=name, expected_ndim=1)
              for name in chain(
                  self.static_feature_dims.keys(),
                  self.dynamic_cardinalities.keys(),
              )
          ]
          + [
              AsNumpyArray(field=name, expected_ndim=2)
              for name in self.dynamic_feature_dims.keys()
          ]
          + [
              AddObservedValuesIndicator(
                  target_field=FieldName.TARGET,
                  output_field=FieldName.OBSERVED_VALUES,
              ),
              AddTimeFeatures(
                  start_field=FieldName.START,
                  target_field=FieldName.TARGET,
                  output_field=FieldName.FEAT_TIME,
                  time_features=self.time_features,
                  pred_length=self.prediction_length,
              ),
              AddAgeFeature(
                  target_field=FieldName.TARGET,
                  output_field=FieldName.FEAT_AGE,
                  pred_length=self.prediction_length,
                  log_scale=True,
              ),
          ]
      )
  
      if self.static_cardinalities:
          transforms.extend(
              [
                  VstackFeatures(
                      output_field=FieldName.FEAT_STATIC_CAT,
                      input_fields=list(
                          self.static_cardinalities.keys()
                      ),
                      h_stack=True,
                  ),
                  AsNumpyArray(
                      field=FieldName.FEAT_STATIC_CAT,
                      expected_ndim=1,
                      dtype=np.long,
                  ),
              ]
          )
      else:
          transforms.extend(
              [
                  SetField(
                      output_field=FieldName.FEAT_STATIC_CAT,
                      value=[0],
                  ),
                  AsNumpyArray(
                      field=FieldName.FEAT_STATIC_CAT,
                      expected_ndim=1,
                      dtype=np.long,
                  ),
              ]
          )
  
      if self.static_feature_dims:
          transforms.append(
              VstackFeatures(
                  output_field=FieldName.FEAT_STATIC_REAL,
                  input_fields=list(self.static_feature_dims.keys()),
                  h_stack=True,
              )
          )
      else:
          transforms.extend(
              [
                  SetField(
                      output_field=FieldName.FEAT_STATIC_REAL,
                      value=[0.0],
                  ),
                  AsNumpyArray(
                      field=FieldName.FEAT_STATIC_REAL, expected_ndim=1
                  ),
              ]
          )
  
      if self.dynamic_cardinalities:
          transforms.extend(
              [
                  VstackFeatures(
                      output_field=FieldName.FEAT_DYNAMIC_CAT,
                      input_fields=list(
                          self.dynamic_cardinalities.keys()
                      ),
                  ),
                  AsNumpyArray(
                      field=FieldName.FEAT_DYNAMIC_CAT,
                      expected_ndim=2,
                      dtype=np.long,
                  ),
              ]
          )
      else:
          transforms.extend(
              [
                  SetField(
                      output_field=FieldName.FEAT_DYNAMIC_CAT,
                      value=[[0]],
                  ),
                  AsNumpyArray(
                      field=FieldName.FEAT_DYNAMIC_CAT,
                      expected_ndim=2,
                      dtype=np.long,
                  ),
                  BroadcastTo(
                      field=FieldName.FEAT_DYNAMIC_CAT,
                      ext_length=self.prediction_length,
                  ),
              ]
          )
  
      input_fields = [FieldName.FEAT_TIME, FieldName.FEAT_AGE]
      if self.dynamic_feature_dims:
          input_fields += list(self.dynamic_feature_dims.keys())
      transforms.append(
          VstackFeatures(
              input_fields=input_fields,
              output_field=FieldName.FEAT_DYNAMIC_REAL,
          )
      )
  
      if self.past_dynamic_cardinalities:
          transforms.extend(
              [
                  VstackFeatures(
                      output_field=FieldName.PAST_FEAT_DYNAMIC + "_cat",
                      input_fields=list(
                          self.past_dynamic_cardinalities.keys()
                      ),
                  ),
                  AsNumpyArray(
                      field=FieldName.PAST_FEAT_DYNAMIC + "_cat",
                      expected_ndim=2,
                      dtype=np.long,
                  ),
              ]
          )
      else:
          transforms.extend(
              [
                  SetField(
                      output_field=FieldName.PAST_FEAT_DYNAMIC + "_cat",
                      value=[[0]],
                  ),
                  AsNumpyArray(
                      field=FieldName.PAST_FEAT_DYNAMIC + "_cat",
                      expected_ndim=2,
                      dtype=np.long,
                  ),
                  BroadcastTo(
                      field=FieldName.PAST_FEAT_DYNAMIC + "_cat"
                  ),
              ]
          )
  
      if self.past_dynamic_feature_dims:
          transforms.append(
              VstackFeatures(
                  output_field=FieldName.PAST_FEAT_DYNAMIC_REAL,
                  input_fields=list(
                      self.past_dynamic_feature_dims.keys()
                  ),
              )
          )
      else:
          transforms.extend(
              [
                  SetField(
                      output_field=FieldName.PAST_FEAT_DYNAMIC_REAL,
                      value=[[0.0]],
                  ),
                  AsNumpyArray(
                      field=FieldName.PAST_FEAT_DYNAMIC_REAL,
                      expected_ndim=2,
                  ),
                  BroadcastTo(field=FieldName.PAST_FEAT_DYNAMIC_REAL),
              ]
          )
  
      return Chain(transforms)
  
imports: from itertools import chain
  from typing import List, Optional, Dict
  import numpy
  import torch
  from gluonts.core.component import validated
  from gluonts.dataset.field_names import FieldName
  from gluonts.model.forecast_generator import QuantileForecastGenerator
  from gluonts.model.predictor import Predictor
  from gluonts.time_feature import TimeFeature, time_features_from_frequency_str
  from gluonts.torch.model.predictor import PyTorchPredictor
  from gluonts.torch.util import copy_parameters
  from gluonts.transform import Transformation, Chain, ValidationSplitSampler, TestSplitSampler, ExpectedNumInstanceSampler, AddAgeFeature, AsNumpyArray, AddObservedValuesIndicator, AddTimeFeatures, VstackFeatures, SetField
  from pts import Trainer
  from pts.model import PyTorchEstimator
  from pts.model.utils import get_module_forward_input_names
  from .tft_network import TemporalFusionTransformerPredictionNetwork, TemporalFusionTransformerTrainingNetwork
  from .tft_transform import BroadcastTo, TFTInstanceSplitter
label_desc: Use image node_id 2 for calling the TemporalFusionTransformerEstimator obj's underlying member method code with example usage: obj.create_transformation() and returns: Chain