def forward(
        self,
        latent_i: torch.Tensor,
        latent_o: torch.Tensor,
        images: torch.Tensor,
        fake: torch.Tensor,
        pred_real: torch.Tensor,
        pred_fake: torch.Tensor,
    ) -> torch.Tensor:
        """Compute the generator loss for a batch.

        Args:
            latent_i (torch.Tensor): Latent features from the first encoder.
            latent_o (torch.Tensor): Latent features from the second encoder.
            images (torch.Tensor): Real images that served as generator input.
            fake (torch.Tensor): Generated/fake images.
            pred_real (torch.Tensor): Discriminator predictions for real images.
            pred_fake (torch.Tensor): Discriminator predictions for fake images.

        Returns:
            torch.Tensor: Combined weighted generator loss.

        Example:
            >>> loss = generator_loss(latent_i, latent_o, images, fake,
            ...                      pred_real, pred_fake)
        """
        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)

        return error_adv * self.wadv + error_con * self.wcon + error_enc * self.wenc
Compute the generator loss for a batch.

        Args:
            latent_i (torch.Tensor): Latent features from the first encoder.
            latent_o (torch.Tensor): Latent features from the second encoder.
            images (torch.Tensor): Real images that served as generator input.
            fake (torch.Tensor): Generated/fake images.
            pred_real (torch.Tensor): Discriminator predictions for real images.
            pred_fake (torch.Tensor): Discriminator predictions for fake images.

        Returns:
            torch.Tensor: Combined weighted generator loss.

        Example:
            >>> loss = generator_loss(latent_i, latent_o, images, fake,
            ...                      pred_real, pred_fake)
        
src/anomalib/models/image/ganomaly/loss.py