code: def __init__(
      self,
      disc_start,
      codebook_weight=1.0,
      pixelloss_weight=1.0,
      disc_num_layers=3,
      disc_in_channels=3,
      disc_factor=1.0,
      disc_weight=1.0,
      perceptual_weight=1.0,
      use_actnorm=False,
      disc_conditional=False,
      disc_ndf=64,
      disc_loss="hinge",
      n_classes=None,
      perceptual_loss="lpips",
      pixel_loss="l1",
  ):
      super().__init__()
      assert disc_loss in ["hinge", "vanilla"]
      assert perceptual_loss in ["lpips", "clips", "dists"]
      assert pixel_loss in ["l1", "l2"]
      self.codebook_weight = codebook_weight
      self.pixel_weight = pixelloss_weight
      if perceptual_loss == "lpips":
          print(f"{self.__class__.__name__}: Running with LPIPS.")
          self.perceptual_loss = LPIPS().eval()
      else:
          raise ValueError(
              f"Unknown perceptual loss: >> {perceptual_loss} <<"
          )
      self.perceptual_weight = perceptual_weight
  
      if pixel_loss == "l1":
          self.pixel_loss = l1
      else:
          self.pixel_loss = l2
  
      self.discriminator = NLayerDiscriminator(
          input_nc=disc_in_channels,
          n_layers=disc_num_layers,
          use_actnorm=use_actnorm,
          ndf=disc_ndf,
      ).apply(weights_init)
      self.discriminator_iter_start = disc_start
      if disc_loss == "hinge":
          self.disc_loss = hinge_d_loss
      elif disc_loss == "vanilla":
          self.disc_loss = vanilla_d_loss
      else:
          raise ValueError(f"Unknown GAN loss '{disc_loss}'.")
      print(f"VQLPIPSWithDiscriminator running with {disc_loss} loss.")
      self.disc_factor = disc_factor
      self.discriminator_weight = disc_weight
      self.disc_conditional = disc_conditional
      self.n_classes = n_classes
  
file_path: compvis-stable-diffusion/ldm/modules/losses/vqperceptual.py
imports: import torch
  from torch import nn
  import torch.nn.functional
  from einops import repeat
  from taming.modules.discriminator.model import NLayerDiscriminator, weights_init
  from taming.modules.losses.lpips import LPIPS
  from taming.modules.losses.vqperceptual import hinge_d_loss, vanilla_d_loss
label_desc: Use image node_id 1 to create a new VQLPIPSWithDiscriminator object from inherited base classes: nn with example: obj = VQLPIPSWithDiscriminator(disc_start, codebook_weight, pixelloss_weight, disc_num_layers, disc_in_channels, disc_factor, disc_weight, perceptual_weight, use_actnorm, disc_conditional, disc_ndf, disc_loss, n_classes, perceptual_loss, pixel_loss)