def forward(self, outputs: torch.Tensor, targets: torch.Tensor) -> torch.Tensor:
        """Calculates loss between ``logits`` and ``target`` tensors."""
        sum_per_class = self._get_sum_per_class(outputs.shape)
        outputs_2 = outputs ** 2
        targets_2 = targets ** 2
        tp = sum_per_class(outputs * targets)
        outputs_per_class = sum_per_class(outputs_2)
        targets_per_class = sum_per_class(targets_2)
        if self.mode == "micro":
            tp = tp.sum()
            outputs_per_class = outputs_per_class.sum()
            targets_per_class = targets_per_class.sum()
        smoothing_dice = 2 * tp / (outputs_per_class + targets_per_class + self.eps)
        if self.mode == "macro":
            smoothing_dice = smoothing_dice.mean()
        if self.mode == "weighted":
            device = smoothing_dice.device
            smoothing_dice = (smoothing_dice * self.weights.to(device)).sum()
        return 1 - smoothing_dice
Calculates loss between ``logits`` and ``target`` tensors.
catalyst/contrib/losses/smoothing_dice.py