class_docstr: Temporal Fusion Transformer neural network.
  
  Partially based on the implementation in github.com/kashif/pytorch-transformer-ts.
  
  Inputs feat_static_real, feat_static_cat and feat_dynamic_real are mandatory.
  Inputs feat_dynamic_cat, past_feat_dynamic_real and past_feat_dynamic_cat are optional.
class_docstr_tok: ["Temporal","Fusion","Transformer","neural","network",".","Partially","based","on","the","implementation","in","github.com\/kashif\/pytorch-transformer-ts",".","Inputs","feat_static_real",",","feat_static_cat","and","feat_dynamic_real","are","mandatory",".","Inputs","feat_dynamic_cat",",","past_feat_dynamic_real","and","past_feat_dynamic_cat","are","optional","."]
code: def forward(
      self,
      past_target: torch.Tensor,  # [N, T]
      past_observed_values: torch.Tensor,  # [N, T]
      feat_static_real: Optional[torch.Tensor],  # [N, D_sr]
      feat_static_cat: Optional[torch.Tensor],  # [N, D_sc]
      feat_dynamic_real: Optional[torch.Tensor],  # [N, T + H, D_dr]
      feat_dynamic_cat: Optional[
          torch.Tensor
      ] = None,  # [N, T + H, D_dc]
      past_feat_dynamic_real: Optional[
          torch.Tensor
      ] = None,  # [N, T, D_pr]
      past_feat_dynamic_cat: Optional[
          torch.Tensor
      ] = None,  # [N, T, D_pc]
  ) -> Tuple[Tuple[torch.Tensor, ...], torch.Tensor, torch.Tensor]:
      (
          past_covariates,  # [[N, T, d_var], ...]
          future_covariates,  # [[N, H, d_var], ...]
          static_covariates,  # [[N, d_var], ...]
          loc,  # [N, 1]
          scale,  # [N, 1]
      ) = self._preprocess(
          past_target=past_target,
          past_observed_values=past_observed_values,
          feat_static_real=feat_static_real,
          feat_static_cat=feat_static_cat,
          feat_dynamic_real=feat_dynamic_real,
          feat_dynamic_cat=feat_dynamic_cat,
          past_feat_dynamic_real=past_feat_dynamic_real,
          past_feat_dynamic_cat=past_feat_dynamic_cat,
      )
  
      static_var, _ = self.static_selector(
          static_covariates
      )  # [N, d_var]
      c_selection = self.selection(static_var).unsqueeze(
          1
      )  # [N, 1, d_var]
      c_enrichment = self.enrichment(static_var).unsqueeze(1)
      c_h = self.state_h(static_var)  # [N, self.d_hidden]
      c_c = self.state_c(static_var)  # [N, self.d_hidden]
      states = [c_h.unsqueeze(0), c_c.unsqueeze(0)]
  
      ctx_input, _ = self.ctx_selector(
          past_covariates, c_selection
      )  # [N, T, d_var]
      tgt_input, _ = self.tgt_selector(
          future_covariates, c_selection
      )  # [N, H, d_var]
  
      encoding = self.temporal_encoder(
          ctx_input, tgt_input, states
      )  # [N, T + H, d_hidden]
      decoding = self.temporal_decoder(
          encoding, c_enrichment, past_observed_values
      )  # [N, H, d_hidden]
      distr_args = self.args_proj(decoding)
      return distr_args, loc, scale
  
file_path: gluonts/src/gluonts/torch/model/tft/module.py
imports: import logging
  from typing import Dict, List, Optional, Tuple
  import torch
  import torch.nn
  from gluonts.core.component import validated
  from gluonts.model import Input, InputSpec
  from gluonts.torch.distributions import Output
  from gluonts.torch.distributions.quantile_output import QuantileOutput
  from gluonts.torch.scaler import StdScaler
  from gluonts.torch.util import weighted_average
  from .layers import FeatureEmbedder, FeatureProjector, GatedResidualNetwork, TemporalFusionDecoder, TemporalFusionEncoder, VariableSelectionNetwork
label_desc: Use image node_id 5 for calling the TemporalFusionTransformerModel obj's underlying member method code with example usage: obj.forward(past_target, past_observed_values, feat_static_real, feat_static_cat, feat_dynamic_real, feat_dynamic_cat, past_feat_dynamic_real, past_feat_dynamic_cat) and returns: distr_args,  loc,  scale