class_docstr: Feature matching loss module.
class_docstr_tok: ["Feature","matching","loss","module","."]
docstr: Calculate feature matching loss.
  
  Args:
      feats_hat (Union[List[List[Tensor]], List[Tensor]]): List of list of
          discriminator outputs or list of discriminator outputs calcuated
          from generator's outputs.
      feats (Union[List[List[Tensor]], List[Tensor]]): List of list of
          discriminator outputs or list of discriminator outputs calcuated
          from groundtruth..
  
  Returns:
      Tensor: Feature matching loss value.
docstr_tok: ["Calculate","feature","matching","loss",".","Args",":","feats_hat","(","Union","[","List","[","List","[","Tensor","]","]",",","List","[","Tensor","]","]",")",":","List","of","list","of","discriminator","outputs","or","list","of","discriminator","outputs","calcuated","from","generator","'s","outputs",".","feats","(","Union","[","List","[","List","[","Tensor","]","]",",","List","[","Tensor","]","]",")",":","List","of","list","of","discriminator","outputs","or","list","of","discriminator","outputs","calcuated","from","groundtruth","..","Returns",":","Tensor",":","Feature","matching","loss","value","."]
code: def forward(
      self,
      feats_hat: Union[List[List[torch.Tensor]], List[torch.Tensor]],
      feats: Union[List[List[torch.Tensor]], List[torch.Tensor]],
  ) -> torch.Tensor:
      """Calculate feature matching loss.
  
      Args:
          feats_hat (Union[List[List[Tensor]], List[Tensor]]): List of list of
              discriminator outputs or list of discriminator outputs calcuated
              from generator's outputs.
          feats (Union[List[List[Tensor]], List[Tensor]]): List of list of
              discriminator outputs or list of discriminator outputs calcuated
              from groundtruth..
  
      Returns:
          Tensor: Feature matching loss value.
  
      """
      feat_match_loss = 0.0
      for i, (feats_hat_, feats_) in enumerate(zip(feats_hat, feats)):
          feat_match_loss_ = 0.0
          if not self.include_final_outputs:
              feats_hat_ = feats_hat_[:-1]
              feats_ = feats_[:-1]
          for j, (feat_hat_, feat_) in enumerate(
              zip(feats_hat_, feats_)
          ):
              feat_match_loss_ += F.l1_loss(feat_hat_, feat_.detach())
          if self.average_by_layers:
              feat_match_loss_ /= j + 1
          feat_match_loss += feat_match_loss_
      if self.average_by_discriminators:
          feat_match_loss /= i + 1
  
      return feat_match_loss
  
imports: from typing import List, Optional, Tuple, Union
  import torch
  import torch.nn.functional
  from espnet2.tts.feats_extract.log_mel_fbank import LogMelFbank
label_desc: Use image node_id 2 for calling the FeatureMatchLoss obj's underlying member method code with example usage: obj.forward(feats_hat, feats) and returns: feat_match_loss