class_docstr: Balanced L1 Loss.
  
  arXiv: https://arxiv.org/pdf/1904.02701.pdf (CVPR 2019)
  
  Args:
      alpha (float): The denominator ``alpha`` in the balanced L1 loss.
          Defaults to 0.5.
      gamma (float): The ``gamma`` in the balanced L1 loss. Defaults to 1.5.
      beta (float, optional): The loss is a piecewise function of prediction
          and target. ``beta`` serves as a threshold for the difference
          between the prediction and target. Defaults to 1.0.
      reduction (str, optional): The method that reduces the loss to a
          scalar. Options are "none", "mean" and "sum".
      loss_weight (float, optional): The weight of the loss. Defaults to 1.0
docstr: Forward function of loss.
  
  Args:
      pred (torch.Tensor): The prediction with shape (N, 4).
      target (torch.Tensor): The learning target of the prediction with
          shape (N, 4).
      weight (torch.Tensor, optional): Sample-wise loss weight with
          shape (N, ).
      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.
          Options are "none", "mean" and "sum".
  
  Returns:
      torch.Tensor: The calculated loss
docstr_tok: ["Forward","function","of","loss",".","Args",":","pred","(","torch.Tensor",")",":","The","prediction","with","shape","(","N",",","4",")",".","target","(","torch.Tensor",")",":","The","learning","target","of","the","prediction","with","shape","(","N",",","4",")",".","weight","(","torch.Tensor",",","optional",")",":","Sample-wise","loss","weight","with","shape","(","N",",",")",".","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",".","Options","are","``","none","''",",","``","mean","''","and","``","sum","''",".","Returns",":","torch.Tensor",":","The","calculated","loss"]
code: def forward(
      self,
      pred,
      target,
      weight=None,
      avg_factor=None,
      reduction_override=None,
      **kwargs,
  ):
      """Forward function of loss.
  
      Args:
          pred (torch.Tensor): The prediction with shape (N, 4).
          target (torch.Tensor): The learning target of the prediction with
              shape (N, 4).
          weight (torch.Tensor, optional): Sample-wise loss weight with
              shape (N, ).
          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.
              Options are "none", "mean" and "sum".
  
      Returns:
          torch.Tensor: The calculated loss
      """
      assert reduction_override in (None, "none", "mean", "sum")
      reduction = (
          reduction_override if reduction_override else self.reduction
      )
      loss_bbox = self.loss_weight * balanced_l1_loss(
          pred,
          target,
          weight,
          alpha=self.alpha,
          gamma=self.gamma,
          beta=self.beta,
          reduction=reduction,
          avg_factor=avg_factor,
          **kwargs,
      )
      return loss_bbox
  
file_path: insightface/detection/scrfd/mmdet/models/losses/balanced_l1_loss.py
imports: import numpy
  import torch
  import torch.nn
  from ..builder import LOSSES
  from .utils import weighted_loss
label_desc: Use image node_id 2 for calling the BalancedL1Loss obj's underlying member method code with example usage: obj.forward(pred, target, weight, avg_factor, reduction_override) and returns: loss_bbox