class_docstr: YOLACT box head used in https://arxiv.org/abs/1904.02689.
  
  Note that YOLACT head is a light version of RetinaNet head.
  Four differences are described as follows:
  
  1. YOLACT box head has three-times fewer anchors.
  2. YOLACT box head shares the convs for box and cls branches.
  3. YOLACT box head uses OHEM instead of Focal loss.
  4. YOLACT box head predicts a set of mask coefficients for each box.
  
  Args:
      num_classes (int): Number of categories excluding the background
          category.
      in_channels (int): Number of channels in the input feature map.
      anchor_generator (dict): Config dict for anchor generator
      loss_cls (dict): Config of classification loss.
      loss_bbox (dict): Config of localization loss.
      num_head_convs (int): Number of the conv layers shared by
          box and cls branches.
      num_protos (int): Number of the mask coefficients.
      use_ohem (bool): If true, ``loss_single_OHEM`` will be used for
          cls loss calculation. If false, ``loss_single`` will be used.
      conv_cfg (dict): Dictionary to construct and config conv layer.
      norm_cfg (dict): Dictionary to construct and config norm layer.
docstr: "See func:``SSDHead.loss``.
docstr_tok: ["``","See","func",":","``","SSDHead.loss","``","."]
code: def loss_single_OHEM(
      self,
      cls_score,
      bbox_pred,
      anchors,
      labels,
      label_weights,
      bbox_targets,
      bbox_weights,
      num_total_samples,
  ):
      """ "See func:``SSDHead.loss``."""
      loss_cls_all = self.loss_cls(cls_score, labels, label_weights)
  
      # FG cat_id: [0, num_classes -1], BG cat_id: num_classes
      pos_inds = (
          ((labels >= 0) & (labels < self.num_classes))
          .nonzero()
          .reshape(-1)
      )
      neg_inds = (labels == self.num_classes).nonzero().view(-1)
  
      num_pos_samples = pos_inds.size(0)
      if num_pos_samples == 0:
          num_neg_samples = neg_inds.size(0)
      else:
          num_neg_samples = (
              self.train_cfg.neg_pos_ratio * num_pos_samples
          )
          if num_neg_samples > neg_inds.size(0):
              num_neg_samples = neg_inds.size(0)
      topk_loss_cls_neg, _ = loss_cls_all[neg_inds].topk(
          num_neg_samples
      )
      loss_cls_pos = loss_cls_all[pos_inds].sum()
      loss_cls_neg = topk_loss_cls_neg.sum()
      loss_cls = (loss_cls_pos + loss_cls_neg) / num_total_samples
      if self.reg_decoded_bbox:
          bbox_pred = self.bbox_coder.decode(anchors, bbox_pred)
      loss_bbox = self.loss_bbox(
          bbox_pred,
          bbox_targets,
          bbox_weights,
          avg_factor=num_total_samples,
      )
      return loss_cls[None], loss_bbox
  
imports: import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from mmcv.cnn import ConvModule, xavier_init
  from mmcv.runner import force_fp32
  from mmdet.core import build_sampler, fast_nms, images_to_levels, multi_apply
  from ..builder import HEADS, build_loss
  from .anchor_head import AnchorHead
label_desc: Use image node_id 6 for calling the YOLACTHead obj's underlying member method code with example usage: obj.loss_single_OHEM(cls_score, bbox_pred, anchors, labels, label_weights, bbox_targets, bbox_weights, num_total_samples) and returns: loss_cls,  loss_bbox