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: "Similiar to func:``AnchorHead._get_bboxes_single``, but
  additionally processes coeff_preds_list and uses fast NMS instead of
  traditional NMS.
  
  Args:
      cls_score_list (list[Tensor]): Box scores for a single scale level
          Has shape (num_anchors * num_classes, H, W).
      bbox_pred_list (list[Tensor]): Box energies / deltas for a single
          scale level with shape (num_anchors * 4, H, W).
      coeff_preds_list (list[Tensor]): Mask coefficients for a single
          scale level with shape (num_anchors * num_protos, H, W).
      mlvl_anchors (list[Tensor]): Box reference for a single scale level
          with shape (num_total_anchors, 4).
      img_shape (tuple[int]): Shape of the input image,
          (height, width, 3).
      scale_factor (ndarray): Scale factor of the image arange as
          (w_scale, h_scale, w_scale, h_scale).
      cfg (mmcv.Config): Test / postprocessing configuration,
          if None, test_cfg would be used.
      rescale (bool): If True, return boxes in original image space.
  
  Returns:
      tuple[Tensor, Tensor, Tensor]: The first item is an (n, 5) tensor,
          where the first 4 columns are bounding box positions
          (tl_x, tl_y, br_x, br_y) and the 5-th column is a score between
          0 and 1. The second item is an (n,) tensor where each item is
          the predicted class label of the corresponding box. The third
          item is an (n, num_protos) tensor where each item is the
          predicted mask coefficients of instance inside the
          corresponding box.
docstr_tok: ["``","Similiar","to","func",":","``","AnchorHead._get_bboxes_single","``",",","but","additionally","processes","coeff_preds_list","and","uses","fast","NMS","instead","of","traditional","NMS",".","Args",":","cls_score_list","(","list","[","Tensor","]",")",":","Box","scores","for","a","single","scale","level","Has","shape","(","num_anchors","*","num_classes",",","H",",","W",")",".","bbox_pred_list","(","list","[","Tensor","]",")",":","Box","energies","\/","deltas","for","a","single","scale","level","with","shape","(","num_anchors","*","4",",","H",",","W",")",".","coeff_preds_list","(","list","[","Tensor","]",")",":","Mask","coefficients","for","a","single","scale","level","with","shape","(","num_anchors","*","num_protos",",","H",",","W",")",".","mlvl_anchors","(","list","[","Tensor","]",")",":","Box","reference","for","a","single","scale","level","with","shape","(","num_total_anchors",",","4",")",".","img_shape","(","tuple","[","int","]",")",":","Shape","of","the","input","image",",","(","height",",","width",",","3",")",".","scale_factor","(","ndarray",")",":","Scale","factor","of","the","image","arange","as","(","w_scale",",","h_scale",",","w_scale",",","h_scale",")",".","cfg","(","mmcv.Config",")",":","Test","\/","postprocessing","configuration",",","if","None",",","test_cfg","would","be","used",".","rescale","(","bool",")",":","If","True",",","return","boxes","in","original","image","space",".","Returns",":","tuple","[","Tensor",",","Tensor",",","Tensor","]",":","The","first","item","is","an","(","n",",","5",")","tensor",",","where","the","first","4","columns","are","bounding","box","positions","(","tl_x",",","tl_y",",","br_x",",","br_y",")","and","the","5-th","column","is","a","score","between","0","and","1",".","The","second","item","is","an","(","n",",",")","tensor","where","each","item","is","the","predicted","class","label","of","the","corresponding","box",".","The","third","item","is","an","(","n",",","num_protos",")","tensor","where","each","item","is","the","predicted","mask","coefficients","of","instance","inside","the","corresponding","box","."]
code: def _get_bboxes_single(
      self,
      cls_score_list,
      bbox_pred_list,
      coeff_preds_list,
      mlvl_anchors,
      img_shape,
      scale_factor,
      cfg,
      rescale=False,
  ):
      """ "Similiar to func:``AnchorHead._get_bboxes_single``, but
      additionally processes coeff_preds_list and uses fast NMS instead of
      traditional NMS.
  
      Args:
          cls_score_list (list[Tensor]): Box scores for a single scale level
              Has shape (num_anchors * num_classes, H, W).
          bbox_pred_list (list[Tensor]): Box energies / deltas for a single
              scale level with shape (num_anchors * 4, H, W).
          coeff_preds_list (list[Tensor]): Mask coefficients for a single
              scale level with shape (num_anchors * num_protos, H, W).
          mlvl_anchors (list[Tensor]): Box reference for a single scale level
              with shape (num_total_anchors, 4).
          img_shape (tuple[int]): Shape of the input image,
              (height, width, 3).
          scale_factor (ndarray): Scale factor of the image arange as
              (w_scale, h_scale, w_scale, h_scale).
          cfg (mmcv.Config): Test / postprocessing configuration,
              if None, test_cfg would be used.
          rescale (bool): If True, return boxes in original image space.
  
      Returns:
          tuple[Tensor, Tensor, Tensor]: The first item is an (n, 5) tensor,
              where the first 4 columns are bounding box positions
              (tl_x, tl_y, br_x, br_y) and the 5-th column is a score between
              0 and 1. The second item is an (n,) tensor where each item is
              the predicted class label of the corresponding box. The third
              item is an (n, num_protos) tensor where each item is the
              predicted mask coefficients of instance inside the
              corresponding box.
      """
      cfg = self.test_cfg if cfg is None else cfg
      assert (
          len(cls_score_list)
          == len(bbox_pred_list)
          == len(mlvl_anchors)
      )
      mlvl_bboxes = []
      mlvl_scores = []
      mlvl_coeffs = []
      for cls_score, bbox_pred, coeff_pred, anchors in zip(
          cls_score_list, bbox_pred_list, coeff_preds_list, mlvl_anchors
      ):
          assert cls_score.size()[-2:] == bbox_pred.size()[-2:]
          cls_score = cls_score.permute(1, 2, 0).reshape(
              -1, self.cls_out_channels
          )
          if self.use_sigmoid_cls:
              scores = cls_score.sigmoid()
          else:
              scores = cls_score.softmax(-1)
          bbox_pred = bbox_pred.permute(1, 2, 0).reshape(-1, 4)
          coeff_pred = coeff_pred.permute(1, 2, 0).reshape(
              -1, self.num_protos
          )
          nms_pre = cfg.get("nms_pre", -1)
          if nms_pre > 0 and scores.shape[0] > nms_pre:
              # Get maximum scores for foreground classes.
              if self.use_sigmoid_cls:
                  max_scores, _ = scores.max(dim=1)
              else:
                  # remind that we set FG labels to [0, num_class-1]
                  # since mmdet v2.0
                  # BG cat_id: num_class
                  max_scores, _ = scores[:, :-1].max(dim=1)
              _, topk_inds = max_scores.topk(nms_pre)
              anchors = anchors[topk_inds, :]
              bbox_pred = bbox_pred[topk_inds, :]
              scores = scores[topk_inds, :]
              coeff_pred = coeff_pred[topk_inds, :]
          bboxes = self.bbox_coder.decode(
              anchors, bbox_pred, max_shape=img_shape
          )
          mlvl_bboxes.append(bboxes)
          mlvl_scores.append(scores)
          mlvl_coeffs.append(coeff_pred)
      mlvl_bboxes = torch.cat(mlvl_bboxes)
      if rescale:
          mlvl_bboxes /= mlvl_bboxes.new_tensor(scale_factor)
      mlvl_scores = torch.cat(mlvl_scores)
      mlvl_coeffs = torch.cat(mlvl_coeffs)
      if self.use_sigmoid_cls:
          # Add a dummy background class to the backend when using sigmoid
          # remind that we set FG labels to [0, num_class-1] since mmdet v2.0
          # BG cat_id: num_class
          padding = mlvl_scores.new_zeros(mlvl_scores.shape[0], 1)
          mlvl_scores = torch.cat([mlvl_scores, padding], dim=1)
      det_bboxes, det_labels, det_coeffs = fast_nms(
          mlvl_bboxes,
          mlvl_scores,
          mlvl_coeffs,
          cfg.score_thr,
          cfg.iou_thr,
          cfg.top_k,
          cfg.max_per_img,
      )
      return det_bboxes, det_labels, det_coeffs
  
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 8 for calling the YOLACTHead obj's underlying member method code with example usage: obj._get_bboxes_single(cls_score_list, bbox_pred_list, coeff_preds_list, mlvl_anchors, img_shape, scale_factor, cfg, rescale) and returns: det_bboxes,  det_labels,  det_coeffs