class_docstr: Quality Focal Loss (QFL) is a variant of `Generalized Focal Loss:
  Learning Qualified and Distributed Bounding Boxes for Dense Object
  Detection <https://arxiv.org/abs/2006.04388>`_.
  
  Args:
      use_sigmoid (bool): Whether sigmoid operation is conducted in QFL.
          Defaults to True.
      beta (float): The beta parameter for calculating the modulating factor.
          Defaults to 2.0.
      reduction (str): Options are "none", "mean" and "sum".
      loss_weight (float): Loss weight of current loss.
      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.
class_docstr_tok: ["Quality","Focal","Loss","(","QFL",")","is","a","variant","of","`","Generalized","Focal","Loss",":","Learning","Qualified","and","Distributed","Bounding","Boxes","for","Dense","Object","Detection","<","https",":","\/\/arxiv.org\/abs\/2006.04388",">","`","_",".","Args",":","use_sigmoid","(","bool",")",":","Whether","sigmoid","operation","is","conducted","in","QFL",".","Defaults","to","True",".","beta","(","float",")",":","The","beta","parameter","for","calculating","the","modulating","factor",".","Defaults","to","2.0.","reduction","(","str",")",":","Options","are","``","none","''",",","``","mean","''","and","``","sum","''",".","loss_weight","(","float",")",":","Loss","weight","of","current","loss",".","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: Forward function.
  
  Args:
      pred (torch.Tensor): Predicted joint representation of
          classification and quality (IoU) estimation with shape (N, C),
          C is the number of classes.
      target (Union(tuple([torch.Tensor]),Torch.Tensor)): The type is
          tuple, it should be included Target category label with
          shape (N,) and target quality label with shape (N,).The type
          is torch.Tensor, the target should be one-hot form with
          soft weights.
      weight (torch.Tensor, optional): The weight of loss for each
          prediction. Defaults to None.
      avg_factor (int, optional): Average factor that is used to average
          the loss. Defaults to None.
      reduction_override (str, optional): The reduction method used to
          override the original reduction method of the loss.
          Defaults to None.
docstr_tok: ["Forward","function",".","Args",":","pred","(","torch.Tensor",")",":","Predicted","joint","representation","of","classification","and","quality","(","IoU",")","estimation","with","shape","(","N",",","C",")",",","C","is","the","number","of","classes",".","target","(","Union","(","tuple","(","[","torch.Tensor","]",")",",","Torch.Tensor",")",")",":","The","type","is","tuple",",","it","should","be","included","Target","category","label","with","shape","(","N",",",")","and","target","quality","label","with","shape","(","N",",",")",".The","type","is","torch.Tensor",",","the","target","should","be","one-hot","form","with","soft","weights",".","weight","(","torch.Tensor",",","optional",")",":","The","weight","of","loss","for","each","prediction",".","Defaults","to","None",".","avg_factor","(","int",",","optional",")",":","Average","factor","that","is","used","to","average","the","loss",".","Defaults","to","None",".","reduction_override","(","str",",","optional",")",":","The","reduction","method","used","to","override","the","original","reduction","method","of","the","loss",".","Defaults","to","None","."]
code: def forward(
      self,
      pred,
      target,
      weight=None,
      avg_factor=None,
      reduction_override=None,
  ):
      """Forward function.
  
      Args:
          pred (torch.Tensor): Predicted joint representation of
              classification and quality (IoU) estimation with shape (N, C),
              C is the number of classes.
          target (Union(tuple([torch.Tensor]),Torch.Tensor)): The type is
              tuple, it should be included Target category label with
              shape (N,) and target quality label with shape (N,).The type
              is torch.Tensor, the target should be one-hot form with
              soft weights.
          weight (torch.Tensor, optional): The weight of loss for each
              prediction. Defaults to None.
          avg_factor (int, optional): Average factor that is used to average
              the loss. Defaults to None.
          reduction_override (str, optional): The reduction method used to
              override the original reduction method of the loss.
              Defaults to None.
      """
      assert reduction_override in (None, "none", "mean", "sum")
      reduction = (
          reduction_override if reduction_override else self.reduction
      )
      if self.use_sigmoid:
          if self.activated:
              calculate_loss_func = quality_focal_loss_with_prob
          else:
              calculate_loss_func = quality_focal_loss
          if isinstance(target, torch.Tensor):
              # the target shape with (N,C) or (N,C,...), which means
              # the target is one-hot form with soft weights.
              calculate_loss_func = partial(
                  quality_focal_loss_tensor_target,
                  activated=self.activated,
              )
  
          loss_cls = self.loss_weight * calculate_loss_func(
              pred,
              target,
              weight,
              beta=self.beta,
              reduction=reduction,
              avg_factor=avg_factor,
          )
      else:
          raise NotImplementedError
      return loss_cls
  
file_path: mmdetection/mmdet/models/losses/gfocal_loss.py
imports: from functools import partial
  import torch
  import torch.nn
  import torch.nn.functional
  from mmdet.models.losses.utils import weighted_loss
  from mmdet.registry import MODELS
label_desc: Use image node_id 2 for calling the QualityFocalLoss obj's underlying member method code with example usage: obj.forward(pred, target, weight, avg_factor, reduction_override) and returns: loss_cls