def compute_losses(
        self,
        batch: torch.Tensor,
        batch_imagenet: torch.Tensor,
        distance_st: torch.Tensor,
    ) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
        """Compute training losses.

        Computes three loss components:
        - Student-teacher loss (hard examples + ImageNet penalty)
        - Autoencoder reconstruction loss
        - Student-autoencoder consistency loss

        Args:
            batch (torch.Tensor): Input batch of images.
            batch_imagenet (torch.Tensor): Batch of ImageNet images.
            distance_st (torch.Tensor): Student-teacher distances.

        Returns:
            tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
                - Student-teacher loss
                - Autoencoder loss
                - Student-autoencoder loss
        """
        # Student loss
        distance_st = reduce_tensor_elems(distance_st)
        d_hard = torch.quantile(distance_st, 0.999)
        loss_hard = torch.mean(distance_st[distance_st >= d_hard])
        student_output_penalty = self.student(batch_imagenet)[:, : self.teacher_out_channels, :, :]
        loss_penalty = torch.mean(student_output_penalty**2)
        loss_st = loss_hard + loss_penalty

        # Autoencoder and Student AE Loss
        aug_img = self.choose_random_aug_image(batch)
        ae_output_aug = self.ae(aug_img, batch.shape[-2:])

        with torch.no_grad():
            teacher_output_aug = self.teacher(aug_img)
            if self.is_set(self.mean_std):
                teacher_output_aug = (teacher_output_aug - self.mean_std["mean"]) / self.mean_std["std"]

        student_output_ae_aug = self.student(aug_img)[:, self.teacher_out_channels :, :, :]

        distance_ae = torch.pow(teacher_output_aug - ae_output_aug, 2)
        distance_stae = torch.pow(ae_output_aug - student_output_ae_aug, 2)

        loss_ae = torch.mean(distance_ae)
        loss_stae = torch.mean(distance_stae)
        return (loss_st, loss_ae, loss_stae)
Compute training losses.

        Computes three loss components:
        - Student-teacher loss (hard examples + ImageNet penalty)
        - Autoencoder reconstruction loss
        - Student-autoencoder consistency loss

        Args:
            batch (torch.Tensor): Input batch of images.
            batch_imagenet (torch.Tensor): Batch of ImageNet images.
            distance_st (torch.Tensor): Student-teacher distances.

        Returns:
            tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
                - Student-teacher loss
                - Autoencoder loss
                - Student-autoencoder loss
        
src/anomalib/models/image/efficient_ad/torch_model.py