class_docstr: Criterion that computes Sørensen-Dice Coefficient loss.
  
  According to [1], we compute the Sørensen-Dice Coefficient as follows:
  
  .. math::
  
      \text{Dice}(x, class) = \frac{2 |X| \cap |Y|}{|X| + |Y|}
  
  Where:
     - :math:`X` expects to be the scores of each class.
     - :math:`Y` expects to be the one-hot tensor with the class labels.
  
  the loss, is finally computed as:
  
  .. math::
  
      \text{loss}(x, class) = 1 - \text{Dice}(x, class)
  
  Reference:
      [1] https://en.wikipedia.org/wiki/S%C3%B8rensen%E2%80%93Dice_coefficient
  
  Args:
      average:
          Reduction applied in multi-class scenario:
          - ``'micro'`` [default]: Calculate the loss across all classes.
          - ``'macro'``: Calculate the loss for each class separately and average the metrics across classes.
      eps: Scalar to enforce numerical stabiliy.
  
  Shape:
      - Pred: :math:`(N, C, H, W)` where C = number of classes.
      - Target: :math:`(N, H, W)` where each value is
        :math:`0 ≤ targets[i] ≤ C-1`.
  
  Example:
      >>> N = 5  # num_classes
      >>> criterion = DiceLoss()
      >>> pred = torch.randn(1, N, 3, 5, requires_grad=True)
      >>> target = torch.empty(1, 3, 5, dtype=torch.long).random_(N)
      >>> output = criterion(pred, target)
      >>> output.backward()
code: def __init__(self, average: str = "micro", eps: float = 1e-8) -> None:
      super().__init__()
      self.average = average
      self.eps = eps
  
file_path: kornia/kornia/losses/dice.py
imports: from __future__ import annotations
  import torch
  from torch import nn
  from kornia.core import Tensor
  from kornia.core.check import KORNIA_CHECK, KORNIA_CHECK_IS_TENSOR
  from kornia.utils.one_hot import one_hot
label_desc: Use image node_id 1 to create a new DiceLoss object from inherited base classes: nn with example: obj = DiceLoss(average, eps)