class_docstr: FreeAnchor RetinaHead used in https://arxiv.org/abs/1909.02466.
  
  Args:
      num_classes (int): Number of categories excluding the background
          category.
      in_channels (int): Number of channels in the input feature map.
      stacked_convs (int): Number of conv layers in cls and reg tower.
          Default: 4.
      conv_cfg (dict): dictionary to construct and config conv layer.
          Default: None.
      norm_cfg (dict): dictionary to construct and config norm layer.
          Default: norm_cfg=dict(type='GN', num_groups=32,
          requires_grad=True).
      pre_anchor_topk (int): Number of boxes that be token in each bag.
      bbox_thr (float): The threshold of the saturated linear function. It is
          usually the same with the IoU threshold used in NMS.
      gamma (float): Gamma parameter in focal loss.
      alpha (float): Alpha parameter in focal loss.
docstr: Compute negative bag loss.
  
  :math:`FL((1 - P_{a_{j} \in A_{+}}) * (1 - P_{j}^{bg}))`.
  
  :math:`P_{a_{j} \in A_{+}}`: Box_probability of matched samples.
  
  :math:`P_{j}^{bg}`: Classification probability of negative samples.
  
  Args:
      cls_prob (Tensor): Classification probability, in shape
          (num_img, num_anchors, num_classes).
      box_prob (Tensor): Box probability, in shape
          (num_img, num_anchors, num_classes).
  
  Returns:
      Tensor: Negative bag loss in shape (num_img, num_anchors, num_classes).
docstr_tok: ["Compute","negative","bag","loss",".",":","math",":","`","FL","(","(","1","-","P_","{","a_","{","j","}","\\in","A_","{","+","}","}",")","*","(","1","-","P_","{","j","}","^","{","bg","}",")",")","`",".",":","math",":","`","P_","{","a_","{","j","}","\\in","A_","{","+","}","}","`",":","Box_probability","of","matched","samples",".",":","math",":","`","P_","{","j","}","^","{","bg","}","`",":","Classification","probability","of","negative","samples",".","Args",":","cls_prob","(","Tensor",")",":","Classification","probability",",","in","shape","(","num_img",",","num_anchors",",","num_classes",")",".","box_prob","(","Tensor",")",":","Box","probability",",","in","shape","(","num_img",",","num_anchors",",","num_classes",")",".","Returns",":","Tensor",":","Negative","bag","loss","in","shape","(","num_img",",","num_anchors",",","num_classes",")","."]
code: def negative_bag_loss(self, cls_prob, box_prob):
      """Compute negative bag loss.
  
      :math:`FL((1 - P_{a_{j} \in A_{+}}) * (1 - P_{j}^{bg}))`.
  
      :math:`P_{a_{j} \in A_{+}}`: Box_probability of matched samples.
  
      :math:`P_{j}^{bg}`: Classification probability of negative samples.
  
      Args:
          cls_prob (Tensor): Classification probability, in shape
              (num_img, num_anchors, num_classes).
          box_prob (Tensor): Box probability, in shape
              (num_img, num_anchors, num_classes).
  
      Returns:
          Tensor: Negative bag loss in shape (num_img, num_anchors, num_classes).
      """  # noqa: E501, W605
      prob = cls_prob * (1 - box_prob)
      # There are some cases when neg_prob = 0.
      # This will cause the neg_prob.log() to be inf without clamp.
      prob = prob.clamp(min=EPS, max=1 - EPS)
      negative_bag_loss = prob**self.gamma * F.binary_cross_entropy(
          prob, torch.zeros_like(prob), reduction="none"
      )
      return (1 - self.alpha) * negative_bag_loss
  
file_path: insightface/detection/scrfd/mmdet/models/dense_heads/free_anchor_retina_head.py
imports: import torch
  import torch.nn.functional
  from mmdet.core import bbox_overlaps
  from ..builder import HEADS
  from .retina_head import RetinaHead
label_desc: Use image node_id 4 for calling the FreeAnchorRetinaHead obj's underlying member method code with example usage: obj.negative_bag_loss(cls_prob, box_prob) and returns: unknown