class_docstr: Generator loss for the GANomaly model.
  
  Args:
      wadv (int, optional): Weight for adversarial loss. Defaults to 1.
      wcon (int, optional): Image regeneration weight. Defaults to 50.
      wenc (int, optional): Latent vector encoder weight. Defaults to 1.
docstr: Compute the loss for a batch.
  
  Args:
      latent_i (Tensor): Latent features of the first encoder.
      latent_o (Tensor): Latent features of the second encoder.
      images (Tensor): Real image that served as input of the generator.
      fake (Tensor): Generated image.
      pred_real (Tensor): Discriminator predictions for the real image.
      pred_fake (Tensor): Discriminator predictions for the fake image.
  
  Returns:
      Tensor: The computed generator loss.
docstr_tok: ["Compute","the","loss","for","a","batch",".","Args",":","latent_i","(","Tensor",")",":","Latent","features","of","the","first","encoder",".","latent_o","(","Tensor",")",":","Latent","features","of","the","second","encoder",".","images","(","Tensor",")",":","Real","image","that","served","as","input","of","the","generator",".","fake","(","Tensor",")",":","Generated","image",".","pred_real","(","Tensor",")",":","Discriminator","predictions","for","the","real","image",".","pred_fake","(","Tensor",")",":","Discriminator","predictions","for","the","fake","image",".","Returns",":","Tensor",":","The","computed","generator","loss","."]
code: def forward(
      self,
      latent_i: Tensor,
      latent_o: Tensor,
      images: Tensor,
      fake: Tensor,
      pred_real: Tensor,
      pred_fake: Tensor,
  ) -> Tensor:
      """Compute the loss for a batch.
  
      Args:
          latent_i (Tensor): Latent features of the first encoder.
          latent_o (Tensor): Latent features of the second encoder.
          images (Tensor): Real image that served as input of the generator.
          fake (Tensor): Generated image.
          pred_real (Tensor): Discriminator predictions for the real image.
          pred_fake (Tensor): Discriminator predictions for the fake image.
  
      Returns:
          Tensor: The computed generator loss.
      """
      error_enc = self.loss_enc(latent_i, latent_o)
      error_con = self.loss_con(images, fake)
      error_adv = self.loss_adv(pred_real, pred_fake)
  
      loss = (
          error_adv * self.wadv
          + error_con * self.wcon
          + error_enc * self.wenc
      )
      return loss
  
file_path: anomalib/src/anomalib/models/ganomaly/loss.py
imports: from __future__ import annotations
  import torch
  from torch import Tensor, nn
label_desc: Use image node_id 2 for calling the GeneratorLoss obj's underlying member method code with example usage: obj.forward(latent_i, latent_o, images, fake, pred_real, pred_fake) and returns: loss