docstr: `Focal Loss <https://arxiv.org/abs/1708.02002>`_
  
  Args:
      use_sigmoid (bool, optional): Whether to the prediction is
          used for sigmoid or softmax. Defaults to True.
      gamma (float, optional): The gamma for calculating the modulating
          factor. Defaults to 2.0.
      alpha (float, optional): A balanced form for Focal Loss.
          Defaults to 0.25.
      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.
      activated (bool, optional): Whether the input is activated.
          If True, it means the input has been activated and can be
          treated as probabilities. Else, it should be treated as logits.
          Defaults to False.
docstr_tok: ["`","Focal","Loss","<","https",":","\/\/arxiv.org\/abs\/1708.02002",">","`","_","Args",":","use_sigmoid","(","bool",",","optional",")",":","Whether","to","the","prediction","is","used","for","sigmoid","or","softmax",".","Defaults","to","True",".","gamma","(","float",",","optional",")",":","The","gamma","for","calculating","the","modulating","factor",".","Defaults","to","2.0.","alpha","(","float",",","optional",")",":","A","balanced","form","for","Focal","Loss",".","Defaults","to","0.25.","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.","activated","(","bool",",","optional",")",":","Whether","the","input","is","activated",".","If","True",",","it","means","the","input","has","been","activated","and","can","be","treated","as","probabilities",".","Else",",","it","should","be","treated","as","logits",".","Defaults","to","False","."]
code: def __init__(
      self,
      use_sigmoid=True,
      gamma=2.0,
      alpha=0.25,
      reduction="mean",
      loss_weight=1.0,
      activated=False,
  ):
      """`Focal Loss <https://arxiv.org/abs/1708.02002>`_
  
      Args:
          use_sigmoid (bool, optional): Whether to the prediction is
              used for sigmoid or softmax. Defaults to True.
          gamma (float, optional): The gamma for calculating the modulating
              factor. Defaults to 2.0.
          alpha (float, optional): A balanced form for Focal Loss.
              Defaults to 0.25.
          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.
          activated (bool, optional): Whether the input is activated.
              If True, it means the input has been activated and can be
              treated as probabilities. Else, it should be treated as logits.
              Defaults to False.
      """
      super(FocalLoss, self).__init__()
      assert (
          use_sigmoid is True
      ), "Only sigmoid focal loss supported now."
      self.use_sigmoid = use_sigmoid
      self.gamma = gamma
      self.alpha = alpha
      self.reduction = reduction
      self.loss_weight = loss_weight
      self.activated = activated
  
imports: import torch
  import torch.nn
  import torch.nn.functional
  from mmcv.ops import sigmoid_focal_loss
  from mmdet.registry import MODELS
  from .accuracy import accuracy
  from .utils import weight_reduce_loss
label_desc: Use image node_id 1 to create a new FocalLoss object from inherited base classes: nn with example: obj = FocalLoss(use_sigmoid, gamma, alpha, reduction, loss_weight, activated)