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.
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","."]
docstr: Forward function.
  Args:
      pred (Tensor): Predicted joint representation of
          classification and quality (IoU) estimation with shape (N, C),
          C is the number of classes.
      target (tuple([Tensor])): Target category label with shape
          (N,) and target quality label with shape (N,).
      weight (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.
docstr_tok: ["Forward","function",".","Args",":","pred","(","Tensor",")",":","Predicted","joint","representation","of","classification","and","quality","(","IoU",")","estimation","with","shape","(","N",",","C",")",",","C","is","the","number","of","classes",".","target","(","tuple","(","[","Tensor","]",")",")",":","Target","category","label","with","shape","(","N",",",")","and","target","quality","label","with","shape","(","N",",",")",".","weight","(","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","."]
code: def forward(self, pred, target, weight=None, avg_factor=None):
      """Forward function.
      Args:
          pred (Tensor): Predicted joint representation of
              classification and quality (IoU) estimation with shape (N, C),
              C is the number of classes.
          target (tuple([Tensor])): Target category label with shape
              (N,) and target quality label with shape (N,).
          weight (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.
      """
  
      loss = self.loss_weight * quality_focal_loss(
          pred, target, beta=self.beta, use_sigmoid=self.use_sigmoid
      )
  
      if weight is not None:
          loss = loss * weight
      if avg_factor is None:
          if self.reduction == "none":
              return loss
          elif self.reduction == "mean":
              return loss.mean()
          elif self.reduction == "sum":
              return loss.sum()
      else:
          # if reduction is mean, then average the loss by avg_factor
          if self.reduction == "mean":
              loss = loss.sum() / avg_factor
          # if reduction is 'none', then do nothing, otherwise raise an error
          elif self.reduction != "none":
              raise ValueError(
                  'avg_factor can not be used with reduction="sum"'
              )
      return loss
  
file_path: PaddleDetection/ppdet/modeling/losses/gfocal_loss.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import numpy
  import paddle
  import paddle.nn
  import paddle.nn.functional
  from ppdet.core.workspace import register, serializable
  from ppdet.modeling import ops
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) and returns: loss, loss, loss, loss