class_docstr: Discriminator loss for the GANomaly model.
docstr: Compute the loss for a predicted batch.
  
  Args:
      pred_real (Tensor): Discriminator predictions for the real image.
      pred_fake (Tensor): Discriminator predictions for the fake image.
  
  Returns:
      Tensor: The computed discriminator loss.
docstr_tok: ["Compute","the","loss","for","a","predicted","batch",".","Args",":","pred_real","(","Tensor",")",":","Discriminator","predictions","for","the","real","image",".","pred_fake","(","Tensor",")",":","Discriminator","predictions","for","the","fake","image",".","Returns",":","Tensor",":","The","computed","discriminator","loss","."]
code: def forward(self, pred_real: Tensor, pred_fake: Tensor) -> Tensor:
      """Compute the loss for a predicted batch.
  
      Args:
          pred_real (Tensor): Discriminator predictions for the real image.
          pred_fake (Tensor): Discriminator predictions for the fake image.
  
      Returns:
          Tensor: The computed discriminator loss.
      """
      error_discriminator_real = self.loss_bce(
          pred_real,
          torch.ones(
              size=pred_real.shape,
              dtype=torch.float32,
              device=pred_real.device,
          ),
      )
      error_discriminator_fake = self.loss_bce(
          pred_fake,
          torch.zeros(
              size=pred_fake.shape,
              dtype=torch.float32,
              device=pred_fake.device,
          ),
      )
      loss_discriminator = (
          error_discriminator_fake + error_discriminator_real
      ) * 0.5
      return loss_discriminator
  
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 DiscriminatorLoss obj's underlying member method code with example usage: obj.forward(pred_real, pred_fake) and returns: loss_discriminator