code: def __init__(
      self,
      input_size: int,
      d_model: int,
      num_heads: int,
      act_type: str,
      dropout_rate: float,
      dim_feedforward_scale: int,
      num_encoder_layers: int,
      num_decoder_layers: int,
      history_length: int,
      context_length: int,
      prediction_length: int,
      distr_output: DistributionOutput,
      cardinality: List[int],
      embedding_dimension: List[int],
      lags_seq: List[int],
      scaling: bool = True,
      **kwargs,
  ) -> None:
      super().__init__(**kwargs)
  
      self.history_length = history_length
      self.context_length = context_length
      self.prediction_length = prediction_length
      self.scaling = scaling
      self.cardinality = cardinality
      self.embedding_dimension = embedding_dimension
      self.distr_output = distr_output
  
      assert len(set(lags_seq)) == len(
          lags_seq
      ), "no duplicated lags allowed!"
      lags_seq.sort()
  
      self.lags_seq = lags_seq
  
      self.target_shape = distr_output.event_shape
  
      # [B, T, input_size] -> [B, T, d_model]
      self.encoder_input = nn.Linear(input_size, d_model)
      self.decoder_input = nn.Linear(input_size, d_model)
  
      # [B, T, d_model] where d_model / num_heads is int
      self.transformer = nn.Transformer(
          d_model=d_model,
          nhead=num_heads,
          num_encoder_layers=num_encoder_layers,
          num_decoder_layers=num_decoder_layers,
          dim_feedforward=dim_feedforward_scale * d_model,
          dropout=dropout_rate,
          activation=act_type,
      )
  
      self.proj_dist_args = distr_output.get_args_proj(d_model)
  
      self.embedder = FeatureEmbedder(
          cardinalities=cardinality,
          embedding_dims=embedding_dimension,
      )
  
      if scaling:
          self.scaler = MeanScaler(keepdim=True)
      else:
          self.scaler = NOPScaler(keepdim=True)
  
      # mask
      self.register_buffer(
          "tgt_mask",
          self.transformer.generate_square_subsequent_mask(
              prediction_length
          ),
      )
  
file_path: gluonts/src/gluonts/nursery/robust-mts-attack/pts/model/transformer/transformer_network.py
imports: from typing import List, Optional, Tuple
  import torch
  import torch.nn
  from gluonts.core.component import validated
  from gluonts.torch.modules.distribution_output import DistributionOutput
  from pts.modules import MeanScaler, NOPScaler, FeatureEmbedder
label_desc: Use image node_id 1 to create a new TransformerNetwork object from inherited base classes: nn with example: obj = TransformerNetwork(input_size, d_model, num_heads, act_type, dropout_rate, dim_feedforward_scale, num_encoder_layers, num_decoder_layers, history_length, context_length, prediction_length, distr_output, cardinality, embedding_dimension, lags_seq, scaling)