code: def forward(
      self,
      src_data: Tensor,
      tgt_data: Tensor,
      src_feats: Optional[Tensor] = None,
      tgt_feats: Optional[Tensor] = None,
      src_nan_mask: Optional[BoolTensor] = None,
      tgt_nan_mask: Optional[BoolTensor] = None,
      src_length: Optional[LongTensor] = None,
      tgt_length: Optional[LongTensor] = None,
  ) -> Tensor:
      gen_loss = super(AdversarialDomAdaptEstimator, self).forward(
          src_data,
          tgt_data,
          src_feats,
          tgt_feats,
          src_nan_mask,
          tgt_nan_mask,
          src_length,
          tgt_length,
      )
  
      batch_size = gen_loss.size(0)
      src_prob_domain = self.src.prob_domain.view(batch_size, -1)
      tgt_prob_domain = self.tgt.prob_domain.view(batch_size, -1)
      adv_type = "grad_rev"
      # adv_type = 'label_inv'
  
      # disc_loss = -log p(is_src | shape_src) - log(1 - p(is_src|shape_tgt))
      disc_loss = -src_prob_domain.mean(dim=1) - pt.log(
          1.0 - tgt_prob_domain.exp() + 1e-10
      ).mean(dim=1)
      if self._generative:
          if adv_type == "grad_rev":
              # DANN: gradient reversal operation
              # Generative model maximizes discriminative loss
              loss = gen_loss - self.disc_lambda * disc_loss
          elif adv_type == "label_inv":
              # ADDA: GAN-style minimax game
              # Invert the label of target data to make pseudo source samples
              # Do not update for real source samples
              # invert_tgt_loss = -log p(is_src | shape_tgt)
              invert_tgt_loss = -tgt_prob_domain.mean(dim=1)
              loss = gen_loss - self.disc_lambda * invert_tgt_loss
      else:
          loss = disc_loss
  
      return loss
  
file_path: gluonts/src/gluonts/nursery/daf/estimator/domains.py
imports: from typing import Optional, List, Tuple, Union, Iterator
  from collections import defaultdict
  import warnings
  import math
  import torch
  from torch import Tensor, LongTensor, BoolTensor
  from torch import nn
  from torch.nn import Parameter, functional
  from .modules import AttentionEstimator, AdversarialEstimator
  from ..network import AttentionKernel, AttentionBlock, AdversarialBlock
label_desc: Use image node_id 4 for calling the AdversarialDomAdaptEstimator obj's underlying member method code with example usage: obj.forward(src_data, tgt_data, src_feats, tgt_feats, src_nan_mask, tgt_nan_mask, src_length, tgt_length) and returns: loss