def trunc_l1_loss(self, pred: torch.Tensor, target: torch.Tensor) -> torch.Tensor:
        """Calculate the truncated L1 loss between `pred` and `target`.

        Args:
            pred (torch.Tensor): predicted values.
            target (torch.Tensor): target GT values.

        Returns:
            torch.Tensor: L1 truncated loss value.
        """
        normal_scores = pred[target == 0]
        anomalous_scores = pred[target > 0]
        # push normal towards negative numbers
        true_loss = torch.clip(normal_scores + self.th, min=0)
        # push anomalous towards positive numbers
        fake_loss = torch.clip(-anomalous_scores + self.th, min=0)

        true_loss = true_loss.mean() if len(true_loss) else torch.tensor(0)
        fake_loss = fake_loss.mean() if len(fake_loss) else torch.tensor(0)

        return true_loss + fake_loss
Calculate the truncated L1 loss between `pred` and `target`.

        Args:
            pred (torch.Tensor): predicted values.
            target (torch.Tensor): target GT values.

        Returns:
            torch.Tensor: L1 truncated loss value.
        
src/anomalib/models/image/supersimplenet/loss.py