def _get_sum_per_class(
        self, outputs_shape: List[int]
    ) -> Callable[[torch.Tensor], torch.Tensor]:
        """
        Creates a channel summing function

        Args:
            outputs_shape: shape of output tensor

        Returns:
             function that sums tensors over all channels except the
             classification

        """
        n_dims = len(outputs_shape)
        dims = list(range(n_dims))
        # support negative index
        if self.class_dim < 0:
            self.class_dim = n_dims + self.class_dim
        dims.pop(self.class_dim)
        sum_per_class = partial(torch.sum, dim=dims)
        return sum_per_class

        Creates a channel summing function

        Args:
            outputs_shape: shape of output tensor

        Returns:
             function that sums tensors over all channels except the
             classification

        
catalyst/contrib/losses/smoothing_dice.py