docstr: `Varifocal Loss <https://arxiv.org/abs/2008.13367>`_
  
  Args:
      use_sigmoid (bool, optional): Whether the prediction is
          used for sigmoid or softmax. Defaults to True.
      alpha (float, optional): A balance factor for the negative part of
          Varifocal Loss, which is different from the alpha of Focal
          Loss. Defaults to 0.75.
      gamma (float, optional): The gamma for calculating the modulating
          factor. Defaults to 2.0.
      iou_weighted (bool, optional): Whether to weight the loss of the
          positive examples with the iou target. Defaults to True.
      reduction (str, optional): The method used to reduce the loss into
          a scalar. Defaults to 'mean'. Options are "none", "mean" and
          "sum".
      loss_weight (float, optional): Weight of loss. Defaults to 1.0.
docstr_tok: ["`","Varifocal","Loss","<","https",":","\/\/arxiv.org\/abs\/2008.13367",">","`","_","Args",":","use_sigmoid","(","bool",",","optional",")",":","Whether","the","prediction","is","used","for","sigmoid","or","softmax",".","Defaults","to","True",".","alpha","(","float",",","optional",")",":","A","balance","factor","for","the","negative","part","of","Varifocal","Loss",",","which","is","different","from","the","alpha","of","Focal","Loss",".","Defaults","to","0.75.","gamma","(","float",",","optional",")",":","The","gamma","for","calculating","the","modulating","factor",".","Defaults","to","2.0.","iou_weighted","(","bool",",","optional",")",":","Whether","to","weight","the","loss","of","the","positive","examples","with","the","iou","target",".","Defaults","to","True",".","reduction","(","str",",","optional",")",":","The","method","used","to","reduce","the","loss","into","a","scalar",".","Defaults","to","'mean","'",".","Options","are","``","none","''",",","``","mean","''","and","``","sum","''",".","loss_weight","(","float",",","optional",")",":","Weight","of","loss",".","Defaults","to","1.0","."]
code: def __init__(
      self,
      use_sigmoid=True,
      alpha=0.75,
      gamma=2.0,
      iou_weighted=True,
      reduction="mean",
      loss_weight=1.0,
  ):
      """`Varifocal Loss <https://arxiv.org/abs/2008.13367>`_
  
      Args:
          use_sigmoid (bool, optional): Whether the prediction is
              used for sigmoid or softmax. Defaults to True.
          alpha (float, optional): A balance factor for the negative part of
              Varifocal Loss, which is different from the alpha of Focal
              Loss. Defaults to 0.75.
          gamma (float, optional): The gamma for calculating the modulating
              factor. Defaults to 2.0.
          iou_weighted (bool, optional): Whether to weight the loss of the
              positive examples with the iou target. Defaults to True.
          reduction (str, optional): The method used to reduce the loss into
              a scalar. Defaults to 'mean'. Options are "none", "mean" and
              "sum".
          loss_weight (float, optional): Weight of loss. Defaults to 1.0.
      """
      super(VarifocalLoss, self).__init__()
      assert (
          use_sigmoid is True
      ), "Only sigmoid varifocal loss supported now."
      assert alpha >= 0.0
      self.use_sigmoid = use_sigmoid
      self.alpha = alpha
      self.gamma = gamma
      self.iou_weighted = iou_weighted
      self.reduction = reduction
      self.loss_weight = loss_weight
  
file_path: insightface/detection/scrfd/mmdet/models/losses/varifocal_loss.py
imports: import torch.nn
  import torch.nn.functional
  from ..builder import LOSSES
  from .utils import weight_reduce_loss
label_desc: Use image node_id 1 to create a new VarifocalLoss object from inherited base classes: nn with example: obj = VarifocalLoss(use_sigmoid, alpha, gamma, iou_weighted, reduction, loss_weight)