class_docstr: Simplest RoI head, with only two fc layers for classification and
  regression respectively.
class_docstr_tok: ["Simplest","RoI","head",",","with","only","two","fc","layers","for","classification","and","regression","respectively","."]
code: def loss(
      self,
      cls_score,
      bbox_pred,
      rois,
      labels,
      label_weights,
      bbox_targets,
      bbox_weights,
      reduction_override=None,
  ):
      losses = dict()
      if cls_score is not None:
          avg_factor = max(
              torch.sum(label_weights > 0).float().item(), 1.0
          )
          if cls_score.numel() > 0:
              losses["loss_cls"] = self.loss_cls(
                  cls_score,
                  labels,
                  label_weights,
                  avg_factor=avg_factor,
                  reduction_override=reduction_override,
              )
              losses["acc"] = accuracy(cls_score, labels)
      if bbox_pred is not None:
          bg_class_ind = self.num_classes
          # 0~self.num_classes-1 are FG, self.num_classes is BG
          pos_inds = (labels >= 0) & (labels < bg_class_ind)
          # do not perform bounding box regression for BG anymore.
          if pos_inds.any():
              if self.reg_decoded_bbox:
                  bbox_pred = self.bbox_coder.decode(
                      rois[:, 1:], bbox_pred
                  )
              if self.reg_class_agnostic:
                  pos_bbox_pred = bbox_pred.view(bbox_pred.size(0), 4)[
                      pos_inds.type(torch.bool)
                  ]
              else:
                  pos_bbox_pred = bbox_pred.view(
                      bbox_pred.size(0), -1, 4
                  )[
                      pos_inds.type(torch.bool),
                      labels[pos_inds.type(torch.bool)],
                  ]
              losses["loss_bbox"] = self.loss_bbox(
                  pos_bbox_pred,
                  bbox_targets[pos_inds.type(torch.bool)],
                  bbox_weights[pos_inds.type(torch.bool)],
                  avg_factor=bbox_targets.size(0),
                  reduction_override=reduction_override,
              )
          else:
              losses["loss_bbox"] = bbox_pred[pos_inds].sum()
      return losses
  
file_path: insightface/detection/scrfd/mmdet/models/roi_heads/bbox_heads/bbox_head.py
imports: import torch
  import torch.nn
  import torch.nn.functional
  from mmcv.runner import auto_fp16, force_fp32
  from torch.nn.modules.utils import _pair
  from mmdet.core import build_bbox_coder, multi_apply, multiclass_nms
  from mmdet.models.builder import HEADS, build_loss
  from mmdet.models.losses import accuracy
label_desc: Use image node_id 6 for calling the BBoxHead obj's underlying member method code with example usage: obj.loss(cls_score, bbox_pred, rois, labels, label_weights, bbox_targets, bbox_weights, reduction_override) and returns: losses