class_docstr: Feature matching loss for adversarial training.
  
  Args:
      loss (nn.Module): Loss to use for feature matching (default=torch.nn.L1).
      normalize (bool): Whether to normalize the loss.
          by number of feature maps.
class_docstr_tok: ["Feature","matching","loss","for","adversarial","training",".","Args",":","loss","(","nn.Module",")",":","Loss","to","use","for","feature","matching","(","default=torch.nn.L1",")",".","normalize","(","bool",")",":","Whether","to","normalize","the","loss",".","by","number","of","feature","maps","."]
code: def forward(
      self,
      fmap_fake: tp.List[torch.Tensor],
      fmap_real: tp.List[torch.Tensor],
  ) -> torch.Tensor:
      assert len(fmap_fake) == len(fmap_real) and len(fmap_fake) > 0
      feat_loss = torch.tensor(0.0, device=fmap_fake[0].device)
      feat_scale = torch.tensor(0.0, device=fmap_fake[0].device)
      n_fmaps = 0
      for feat_fake, feat_real in zip(fmap_fake, fmap_real):
          assert feat_fake.shape == feat_real.shape
          n_fmaps += 1
          feat_loss += self.loss(feat_fake, feat_real)
          feat_scale += torch.mean(torch.abs(feat_real))
  
      if self.normalize:
          feat_loss /= n_fmaps
  
      return feat_loss
  
imports: import typing
  import flashy
  import torch
  import torch.nn
  import torch.nn.functional
label_desc: Use image node_id 2 for calling the FeatureMatchingLoss obj's underlying member method code with example usage: obj.forward(fmap_fake, fmap_real) and returns: feat_loss