docstr: Dice Loss, there are two forms of dice loss is supported:
  
      - the one proposed in `V-Net: Fully Convolutional Neural
          Networks for Volumetric Medical Image Segmentation
          <https://arxiv.org/abs/1606.04797>`_.
      - the dice loss in which the power of the number in the
          denominator is the first power instead of the second
          power.
  
  Args:
      use_sigmoid (bool, optional): Whether to the prediction is
          used for sigmoid or softmax. Defaults to True.
      activate (bool): Whether to activate the predictions inside,
          this will disable the inside sigmoid operation.
          Defaults to True.
      reduction (str, optional): The method used
          to reduce the loss. Options are "none",
          "mean" and "sum". Defaults to 'mean'.
      naive_dice (bool, optional): If false, use the dice
          loss defined in the V-Net paper, otherwise, use the
          naive dice loss in which the power of the number in the
          denominator is the first power instead of the second
          power.Defaults to False.
      loss_weight (float, optional): Weight of loss. Defaults to 1.0.
      eps (float): Avoid dividing by zero. Defaults to 1e-3.
docstr_tok: ["Dice","Loss",",","there","are","two","forms","of","dice","loss","is","supported",":","-","the","one","proposed","in","`","V-Net",":","Fully","Convolutional","Neural","Networks","for","Volumetric","Medical","Image","Segmentation","<","https",":","\/\/arxiv.org\/abs\/1606.04797",">","`","_",".","-","the","dice","loss","in","which","the","power","of","the","number","in","the","denominator","is","the","first","power","instead","of","the","second","power",".","Args",":","use_sigmoid","(","bool",",","optional",")",":","Whether","to","the","prediction","is","used","for","sigmoid","or","softmax",".","Defaults","to","True",".","activate","(","bool",")",":","Whether","to","activate","the","predictions","inside",",","this","will","disable","the","inside","sigmoid","operation",".","Defaults","to","True",".","reduction","(","str",",","optional",")",":","The","method","used","to","reduce","the","loss",".","Options","are","``","none","''",",","``","mean","''","and","``","sum","''",".","Defaults","to","'mean","'",".","naive_dice","(","bool",",","optional",")",":","If","false",",","use","the","dice","loss","defined","in","the","V-Net","paper",",","otherwise",",","use","the","naive","dice","loss","in","which","the","power","of","the","number","in","the","denominator","is","the","first","power","instead","of","the","second","power.Defaults","to","False",".","loss_weight","(","float",",","optional",")",":","Weight","of","loss",".","Defaults","to","1.0.","eps","(","float",")",":","Avoid","dividing","by","zero",".","Defaults","to","1e-3","."]
code: def __init__(
      self,
      use_sigmoid=True,
      activate=True,
      reduction="mean",
      naive_dice=False,
      loss_weight=1.0,
      eps=1e-3,
  ):
      """Dice Loss, there are two forms of dice loss is supported:
  
          - the one proposed in `V-Net: Fully Convolutional Neural
              Networks for Volumetric Medical Image Segmentation
              <https://arxiv.org/abs/1606.04797>`_.
          - the dice loss in which the power of the number in the
              denominator is the first power instead of the second
              power.
  
      Args:
          use_sigmoid (bool, optional): Whether to the prediction is
              used for sigmoid or softmax. Defaults to True.
          activate (bool): Whether to activate the predictions inside,
              this will disable the inside sigmoid operation.
              Defaults to True.
          reduction (str, optional): The method used
              to reduce the loss. Options are "none",
              "mean" and "sum". Defaults to 'mean'.
          naive_dice (bool, optional): If false, use the dice
              loss defined in the V-Net paper, otherwise, use the
              naive dice loss in which the power of the number in the
              denominator is the first power instead of the second
              power.Defaults to False.
          loss_weight (float, optional): Weight of loss. Defaults to 1.0.
          eps (float): Avoid dividing by zero. Defaults to 1e-3.
      """
  
      super(DiceLoss, self).__init__()
      self.use_sigmoid = use_sigmoid
      self.reduction = reduction
      self.naive_dice = naive_dice
      self.loss_weight = loss_weight
      self.eps = eps
      self.activate = activate
  
file_path: dinov2/dinov2/eval/segmentation_m2f/models/losses/dice_loss.py
imports: import torch
  import torch.nn
  from mmseg.models.builder import LOSSES
  from mmseg.models.losses.utils import weight_reduce_loss
label_desc: Use image node_id 1 to create a new DiceLoss object from inherited base classes: nn with example: obj = DiceLoss(use_sigmoid, activate, reduction, naive_dice, loss_weight, eps)