def forward(self, pred_real: torch.Tensor, pred_fake: torch.Tensor) -> torch.Tensor:
        """Compute the discriminator loss for predicted batch.

        Args:
            pred_real (torch.Tensor): Discriminator predictions for real images.
            pred_fake (torch.Tensor): Discriminator predictions for fake images.

        Returns:
            torch.Tensor: Average discriminator loss.

        Example:
            >>> loss = discriminator_loss(pred_real, pred_fake)
        """
        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),
        )
        return (error_discriminator_fake + error_discriminator_real) * 0.5
Compute the discriminator loss for predicted batch.

        Args:
            pred_real (torch.Tensor): Discriminator predictions for real images.
            pred_fake (torch.Tensor): Discriminator predictions for fake images.

        Returns:
            torch.Tensor: Average discriminator loss.

        Example:
            >>> loss = discriminator_loss(pred_real, pred_fake)
        
src/anomalib/models/image/ganomaly/loss.py