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 _preprocess(
      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],  # [N, T + H, D_dc]
      past_feat_dynamic_real: Optional[torch.Tensor],  # [N, T, D_pr]
      past_feat_dynamic_cat: Optional[torch.Tensor],  # [N, T, D_pc]
  ) -> Tuple[
      List[torch.Tensor],
      List[torch.Tensor],
      List[torch.Tensor],
      torch.Tensor,
      torch.Tensor,
  ]:
      past_target, loc, scale = self.scaler(
          data=past_target, weights=past_observed_values
      )
  
      past_covariates = [self.target_proj(past_target.unsqueeze(-1))]
      future_covariates = []
      static_covariates = []
      if self.past_feat_dynamic_proj is not None:
          projs = self.past_feat_dynamic_proj(past_feat_dynamic_real)
          past_covariates.extend(projs)
      if self.past_feat_dynamic_embed is not None:
          embs = self.past_feat_dynamic_embed(past_feat_dynamic_cat)
          past_covariates.extend(embs)
  
      if self.feat_dynamic_proj is not None:
          projs = self.feat_dynamic_proj(feat_dynamic_real)
          for proj in projs:
              ctx_proj = proj[..., : self.context_length, :]
              tgt_proj = proj[..., self.context_length :, :]
              past_covariates.append(ctx_proj)
              future_covariates.append(tgt_proj)
      if self.feat_dynamic_embed is not None:
          embs = self.feat_dynamic_embed(feat_dynamic_cat)
          for emb in embs:
              ctx_emb = emb[..., : self.context_length, :]
              tgt_emb = emb[..., self.context_length :, :]
              past_covariates.append(ctx_emb)
              future_covariates.append(tgt_emb)
  
      if self.feat_static_proj is not None:
          projs = self.feat_static_proj(feat_static_real)
          static_covariates.extend(projs)
      if self.feat_static_embed is not None:
          embs = self.feat_static_embed(feat_static_cat)
          static_covariates.extend(embs)
  
      return (
          past_covariates,
          future_covariates,
          static_covariates,
          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 4 for calling the TemporalFusionTransformerModel obj's underlying member method code with example usage: obj._preprocess(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: past_covariates,  future_covariates,  static_covariates,  loc,  scale