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 loss(
      self,
      past_target: torch.Tensor,  # [N, T]
      past_observed_values: torch.Tensor,  # [N, T]
      future_target: torch.Tensor,  # [N, H]
      future_observed_values: torch.Tensor,  # [N, H]
      feat_static_real: torch.Tensor,  # [N, D_sr]
      feat_static_cat: torch.Tensor,  # [N, D_sc]
      feat_dynamic_real: 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]
  ) -> torch.Tensor:
      distr_args, loc, scale = self(
          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,
      )  # [N, Q, T]
      loss = self.distr_output.loss(
          target=future_target,
          distr_args=distr_args,
          loc=loc,
          scale=scale,
      )
      return weighted_average(
          loss, weights=future_observed_values, dim=-1
      )
  
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 6 for calling the TemporalFusionTransformerModel obj's underlying member method code with example usage: obj.loss(past_target, past_observed_values, future_target, future_observed_values, feat_static_real, feat_static_cat, feat_dynamic_real, feat_dynamic_cat, past_feat_dynamic_real, past_feat_dynamic_cat) and returns: weighted_average