code: def __init__(self, gan_mode: str):
      super().__init__()
      self.loss: nn.Module
      self.gan_mode = gan_mode
      self.register_buffer("real_label", torch.tensor(1.0))
      self.register_buffer("fake_label", torch.tensor(0.0))
      if gan_mode == "lsgan":
          self.loss = nn.MSELoss()
      elif gan_mode == "vanilla":
          self.loss = nn.BCEWithLogitsLoss()
      elif gan_mode in ["wgangp"]:
          self.loss = GradientNormLoss(k=1.0)
      else:
          raise NotImplementedError(
              f"gan mode {gan_mode} not implemented"
          )
      self.ce = nn.CrossEntropyLoss()
  
file_path: carefree-learn/cflearn/losses/gan.py
imports: import torch
  from torch import nn
  from torch import Tensor
  from typing import Optional
  from typing import NamedTuple
  from ..misc.toolkit import get_gradient
label_desc: Use image node_id 1 to create a new GANLoss object from inherited base classes: nn with example: obj = GANLoss(gan_mode)