docstr: Inputs:
      cls_score: N x (C + 1)
      image_labels B x 1
docstr_tok: ["Inputs",":","cls_score",":","N","x","(","C","+","1",")","image_labels","B","x","1"]
code: def image_label_losses(
      self, cls_score, sampling_results, image_labels
  ):
      """
      Inputs:
          cls_score: N x (C + 1)
          image_labels B x 1
      """
      num_inst_per_image = [
          len(pred_instances) for pred_instances in sampling_results
      ]
      cls_score = cls_score.split(
          num_inst_per_image, dim=0
      )  # B x n x (C + 1)
      B = len(cls_score)
      loss = cls_score[0].new_zeros([1])[0]
      for score, labels, pred_instances in zip(
          cls_score, image_labels, sampling_results
      ):
          if score.shape[0] == 0:
              loss += score.new_zeros([1])[0]
              continue
          # find out max-size idx
          bboxes = pred_instances.bboxes
          areas = (bboxes[:, 2] - bboxes[:, 0]) * (
              bboxes[:, 3] - bboxes[:, 1]
          )
          idx = areas[:-1].argmax().item() if len(areas) > 1 else 0
  
          for label in labels:
              target = score.new_zeros(score.shape[1])
              target[label] = 1
              loss_i = F.binary_cross_entropy_with_logits(
                  score[idx], target, reduction="sum"
              )
              loss += loss_i / len(labels)
      loss = loss / B
  
      return loss * self.image_loss_weight
  
imports: import json
  from typing import List, Optional
  import torch
  from mmengine.config import ConfigDict
  from mmengine.structures import InstanceData
  from torch import Tensor
  from torch.nn import functional
  from mmdet.models.layers import multiclass_nms
  from mmdet.models.losses import accuracy
  from mmdet.models.roi_heads.bbox_heads import Shared2FCBBoxHead
  from mmdet.models.utils import empty_instances
  from mmdet.registry import MODELS
  from mmdet.structures.bbox import get_box_tensor, scale_boxes
  from mmdet.utils import ConfigType, InstanceList
label_desc: Use image node_id 5 for calling the DeticBBoxHead obj's underlying member method code with example usage: obj.image_label_losses(cls_score, sampling_results, image_labels) and returns: unknown