class_docstr: Parameters
  ----------
  freq
      Frequency of the data to train on and predict.
  prediction_length
      Length of the prediction horizon.
  context_length
      Number of previous time series values provided as input to the encoder.
      (default: None).
  trainer
      Trainer object to be used (default: Trainer())
  hidden_dim
      Size of the LSTM & transformer hidden states.
  variable_dim
      Size of the feature embeddings.
  num_heads
      Number of attention heads in self-attention layer in the decoder.
  quantiles
      List of quantiles that the model will learn to predict.
      Defaults to [0.1, 0.5, 0.9]
  num_instances_per_series
      Number of samples to generate for each time series when training.
  dropout_rate
      Dropout regularization parameter (default: 0.1).
  time_features
      List of time features, from :py:mod:`gluonts.time_feature`, to use as
      dynamic real features in addition to the provided data (default: None,
      in which case these are automatically determined based on freq).
  static_cardinalities
      Cardinalities of the categorical static features.
  dynamic_cardinalities
      Cardinalities of the categorical dynamic features that are known in the future.
  static_feature_dims
      Sizes of the real-valued static features.
  dynamic_dims
      Sizes of the real-valued dynamic features that are known in the future.
  past_dynamic_features
      List of names of the real-valued dynamic features that are only known in the past.
  train_sampler
      Controls the sampling of windows during training.
  validation_sampler
      Controls the sampling of windows during validation.
  batch_size
      The size of the batches to be used training and prediction.
class_docstr_tok: ["Parameters","--","--","--","--","--","freq","Frequency","of","the","data","to","train","on","and","predict",".","prediction_length","Length","of","the","prediction","horizon",".","context_length","Number","of","previous","time","series","values","provided","as","input","to","the","encoder",".","(","default",":","None",")",".","trainer","Trainer","object","to","be","used","(","default",":","Trainer","(",")",")","hidden_dim","Size","of","the","LSTM","&","transformer","hidden","states",".","variable_dim","Size","of","the","feature","embeddings",".","num_heads","Number","of","attention","heads","in","self-attention","layer","in","the","decoder",".","quantiles","List","of","quantiles","that","the","model","will","learn","to","predict",".","Defaults","to","[","0.1",",","0.5",",","0.9","]","num_instances_per_series","Number","of","samples","to","generate","for","each","time","series","when","training",".","dropout_rate","Dropout","regularization","parameter","(","default",":","0.1",")",".","time_features","List","of","time","features",",","from",":","py",":","mod",":","`","gluonts.time_feature","`",",","to","use","as","dynamic","real","features","in","addition","to","the","provided","data","(","default",":","None",",","in","which","case","these","are","automatically","determined","based","on","freq",")",".","static_cardinalities","Cardinalities","of","the","categorical","static","features",".","dynamic_cardinalities","Cardinalities","of","the","categorical","dynamic","features","that","are","known","in","the","future",".","static_feature_dims","Sizes","of","the","real-valued","static","features",".","dynamic_dims","Sizes","of","the","real-valued","dynamic","features","that","are","known","in","the","future",".","past_dynamic_features","List","of","names","of","the","real-valued","dynamic","features","that","are","only","known","in","the","past",".","train_sampler","Controls","the","sampling","of","windows","during","training",".","validation_sampler","Controls","the","sampling","of","windows","during","validation",".","batch_size","The","size","of","the","batches","to","be","used","training","and","prediction","."]
code: def __init__(
      self,
      freq: str,
      prediction_length: int,
      context_length: Optional[int] = None,
      trainer: Trainer = Trainer(),
      hidden_dim: int = 32,
      variable_dim: Optional[int] = None,
      num_heads: int = 4,
      quantiles: List[float] = [0.1, 0.5, 0.9],
      num_instance_per_series: int = 100,
      dropout_rate: float = 0.1,
      time_features: List[TimeFeature] = [],
      static_cardinalities: Dict[str, int] = {},
      dynamic_cardinalities: Dict[str, int] = {},
      static_feature_dims: Dict[str, int] = {},
      dynamic_feature_dims: Dict[str, int] = {},
      past_dynamic_features: List[str] = [],
      train_sampler: Optional[InstanceSampler] = None,
      validation_sampler: Optional[InstanceSampler] = None,
      batch_size: int = 32,
  ) -> None:
      super().__init__(trainer=trainer, batch_size=batch_size)
      assert (
          prediction_length > 0
      ), "The value of `prediction_length` should be > 0"
      assert (
          context_length is None or context_length > 0
      ), "The value of `context_length` should be > 0"
      assert (
          dropout_rate >= 0
      ), "The value of `dropout_rate` should be >= 0"
  
      self.prediction_length = prediction_length
      self.context_length = context_length or prediction_length
      self.dropout_rate = dropout_rate
      self.hidden_dim = hidden_dim
      self.variable_dim = variable_dim or hidden_dim
      self.num_heads = num_heads
      self.quantiles = quantiles
      self.num_instance_per_series = num_instance_per_series
  
      if not time_features:
          self.time_features = time_features_from_frequency_str(freq)
          if not self.time_features:
              # If time features are empty (as for yearly data), we add a
              # constant feature of 0
              self.time_features = [Constant()]
      else:
          self.time_features = time_features
      self.static_cardinalities = static_cardinalities
      self.dynamic_cardinalities = dynamic_cardinalities
      self.static_feature_dims = static_feature_dims
      self.dynamic_feature_dims = dynamic_feature_dims
      self.past_dynamic_features = past_dynamic_features
  
      self.past_dynamic_cardinalities = {}
      self.past_dynamic_feature_dims = {}
      for name in self.past_dynamic_features:
          if name in self.dynamic_cardinalities:
              self.past_dynamic_cardinalities[
                  name
              ] = self.dynamic_cardinalities.pop(name)
          elif name in self.dynamic_feature_dims:
              self.past_dynamic_feature_dims[
                  name
              ] = self.dynamic_feature_dims.pop(name)
          else:
              raise ValueError(
                  f"Feature name {name} is not provided in feature dicts"
              )
  
      self.train_sampler = (
          train_sampler
          if train_sampler is not None
          else ExpectedNumInstanceSampler(
              num_instances=1.0, min_future=prediction_length
          )
      )
      self.validation_sampler = (
          validation_sampler
          if validation_sampler is not None
          else ValidationSplitSampler(min_future=prediction_length)
      )
  
imports: from functools import partial
  from itertools import chain
  from typing import Dict, List, Optional
  from mxnet.gluon import HybridBlock
  from gluonts.core.component import validated
  from gluonts.dataset.common import Dataset
  from gluonts.dataset.field_names import FieldName
  from gluonts.dataset.loader import DataLoader, TrainDataLoader, ValidationDataLoader
  from gluonts.model.forecast_generator import QuantileForecastGenerator
  from gluonts.mx.batchify import batchify
  from gluonts.mx.model.estimator import GluonEstimator
  from gluonts.mx.model.predictor import RepresentableBlockPredictor
  from gluonts.mx.trainer import Trainer
  from gluonts.mx.util import copy_parameters, get_hybrid_forward_input_names
  from gluonts.time_feature import Constant, TimeFeature, time_features_from_frequency_str
  from gluonts.transform import AddObservedValuesIndicator, AddTimeFeatures, AsNumpyArray, Chain, ExpectedNumInstanceSampler, InstanceSampler, SelectFields, SetField, TestSplitSampler, Transformation, ValidationSplitSampler, VstackFeatures
  from gluonts.transform.split import TFTInstanceSplitter
  from ._network import TemporalFusionTransformerPredictionNetwork, TemporalFusionTransformerTrainingNetwork
  from ._transform import BroadcastTo
label_desc: Use image node_id 1 to create a new TemporalFusionTransformerEstimator object from inherited base classes: GluonEstimator with example: obj = TemporalFusionTransformerEstimator(freq, prediction_length, context_length, trainer, hidden_dim, variable_dim, num_heads, quantiles, num_instance_per_series, dropout_rate, time_features, static_cardinalities, dynamic_cardinalities, static_feature_dims, dynamic_feature_dims, past_dynamic_features, train_sampler, validation_sampler, batch_size)