class_docstr: CondInst box head used in https://arxiv.org/abs/1904.02689.
  
  Note that CondInst Bbox Head is a extension of FCOS head.
  Two differences are described as follows:
  
  1. CondInst box head predicts a set of params for each instance.
  2. CondInst box head return the pos_gt_inds and pos_inds.
  
  Args:
      num_params (int): Number of params for instance segmentation.
class_docstr_tok: ["CondInst","box","head","used","in","https",":","\/\/arxiv.org\/abs\/1904.02689",".","Note","that","CondInst","Bbox","Head","is","a","extension","of","FCOS","head",".","Two","differences","are","described","as","follows",":","1",".","CondInst","box","head","predicts","a","set","of","params","for","each","instance",".","2",".","CondInst","box","head","return","the","pos_gt_inds","and","pos_inds",".","Args",":","num_params","(","int",")",":","Number","of","params","for","instance","segmentation","."]
docstr: Transform a single image's features extracted from the head into
  bbox results.
  
  Args:
      cls_score_list (list[Tensor]): Box scores from all scale
          levels of a single image, each item has shape
          (num_priors * num_classes, H, W).
      bbox_pred_list (list[Tensor]): Box energies / deltas from
          all scale levels of a single image, each item has shape
          (num_priors * 4, H, W).
      score_factor_list (list[Tensor]): Score factor from all scale
          levels of a single image, each item has shape
          (num_priors * 1, H, W).
      param_pred_list (List[Tensor]): Param predition from all scale
          levels of a single image, each item has shape
          (num_priors * num_params, H, W).
      mlvl_points (list[Tensor]): Each element in the list is
          the priors of a single level in feature pyramid.
          It has shape (num_priors, 2)
      mlvl_strides (List[Tensor]):  Each element in the list is
          the stride of a single level in feature pyramid.
          It has shape (num_priors, 1)
      img_meta (dict): Image meta info.
      cfg (mmengine.Config): Test / postprocessing configuration,
          if None, test_cfg would be used.
      rescale (bool): If True, return boxes in original image space.
          Defaults to False.
      with_nms (bool): If True, do nms before return boxes.
          Defaults to True.
  
  Returns:
      :obj:`InstanceData`: Detection results of each image
      after the post process.
      Each item usually contains following keys.
  
          - scores (Tensor): Classification scores, has a shape
            (num_instance, )
          - labels (Tensor): Labels of bboxes, has a shape
            (num_instances, ).
          - bboxes (Tensor): Has a shape (num_instances, 4),
            the last dimension 4 arrange as (x1, y1, x2, y2).
docstr_tok: ["Transform","a","single","image","'s","features","extracted","from","the","head","into","bbox","results",".","Args",":","cls_score_list","(","list","[","Tensor","]",")",":","Box","scores","from","all","scale","levels","of","a","single","image",",","each","item","has","shape","(","num_priors","*","num_classes",",","H",",","W",")",".","bbox_pred_list","(","list","[","Tensor","]",")",":","Box","energies","\/","deltas","from","all","scale","levels","of","a","single","image",",","each","item","has","shape","(","num_priors","*","4",",","H",",","W",")",".","score_factor_list","(","list","[","Tensor","]",")",":","Score","factor","from","all","scale","levels","of","a","single","image",",","each","item","has","shape","(","num_priors","*","1",",","H",",","W",")",".","param_pred_list","(","List","[","Tensor","]",")",":","Param","predition","from","all","scale","levels","of","a","single","image",",","each","item","has","shape","(","num_priors","*","num_params",",","H",",","W",")",".","mlvl_points","(","list","[","Tensor","]",")",":","Each","element","in","the","list","is","the","priors","of","a","single","level","in","feature","pyramid",".","It","has","shape","(","num_priors",",","2",")","mlvl_strides","(","List","[","Tensor","]",")",":","Each","element","in","the","list","is","the","stride","of","a","single","level","in","feature","pyramid",".","It","has","shape","(","num_priors",",","1",")","img_meta","(","dict",")",":","Image","meta","info",".","cfg","(","mmengine.Config",")",":","Test","\/","postprocessing","configuration",",","if","None",",","test_cfg","would","be","used",".","rescale","(","bool",")",":","If","True",",","return","boxes","in","original","image","space",".","Defaults","to","False",".","with_nms","(","bool",")",":","If","True",",","do","nms","before","return","boxes",".","Defaults","to","True",".","Returns",":",":","obj",":","`","InstanceData","`",":","Detection","results","of","each","image","after","the","post","process",".","Each","item","usually","contains","following","keys",".","-","scores","(","Tensor",")",":","Classification","scores",",","has","a","shape","(","num_instance",",",")","-","labels","(","Tensor",")",":","Labels","of","bboxes",",","has","a","shape","(","num_instances",",",")",".","-","bboxes","(","Tensor",")",":","Has","a","shape","(","num_instances",",","4",")",",","the","last","dimension","4","arrange","as","(","x1",",","y1",",","x2",",","y2",")","."]
code: def _predict_by_feat_single(
      self,
      cls_score_list: List[Tensor],
      bbox_pred_list: List[Tensor],
      score_factor_list: List[Tensor],
      param_pred_list: List[Tensor],
      mlvl_points: List[Tensor],
      mlvl_strides: List[Tensor],
      img_meta: dict,
      cfg: ConfigDict,
      rescale: bool = False,
      with_nms: bool = True,
  ) -> InstanceData:
      """Transform a single image's features extracted from the head into
      bbox results.
  
      Args:
          cls_score_list (list[Tensor]): Box scores from all scale
              levels of a single image, each item has shape
              (num_priors * num_classes, H, W).
          bbox_pred_list (list[Tensor]): Box energies / deltas from
              all scale levels of a single image, each item has shape
              (num_priors * 4, H, W).
          score_factor_list (list[Tensor]): Score factor from all scale
              levels of a single image, each item has shape
              (num_priors * 1, H, W).
          param_pred_list (List[Tensor]): Param predition from all scale
              levels of a single image, each item has shape
              (num_priors * num_params, H, W).
          mlvl_points (list[Tensor]): Each element in the list is
              the priors of a single level in feature pyramid.
              It has shape (num_priors, 2)
          mlvl_strides (List[Tensor]):  Each element in the list is
              the stride of a single level in feature pyramid.
              It has shape (num_priors, 1)
          img_meta (dict): Image meta info.
          cfg (mmengine.Config): Test / postprocessing configuration,
              if None, test_cfg would be used.
          rescale (bool): If True, return boxes in original image space.
              Defaults to False.
          with_nms (bool): If True, do nms before return boxes.
              Defaults to True.
  
      Returns:
          :obj:`InstanceData`: Detection results of each image
          after the post process.
          Each item usually contains following keys.
  
              - scores (Tensor): Classification scores, has a shape
                (num_instance, )
              - labels (Tensor): Labels of bboxes, has a shape
                (num_instances, ).
              - bboxes (Tensor): Has a shape (num_instances, 4),
                the last dimension 4 arrange as (x1, y1, x2, y2).
      """
      if score_factor_list[0] is None:
          # e.g. Retina, FreeAnchor, etc.
          with_score_factors = False
      else:
          # e.g. FCOS, PAA, ATSS, etc.
          with_score_factors = True
  
      cfg = self.test_cfg if cfg is None else cfg
      cfg = copy.deepcopy(cfg)
      img_shape = img_meta["img_shape"]
      nms_pre = cfg.get("nms_pre", -1)
  
      mlvl_bbox_preds = []
      mlvl_param_preds = []
      mlvl_valid_points = []
      mlvl_valid_strides = []
      mlvl_scores = []
      mlvl_labels = []
      if with_score_factors:
          mlvl_score_factors = []
      else:
          mlvl_score_factors = None
      for level_idx, (
          cls_score,
          bbox_pred,
          score_factor,
          param_pred,
          points,
          strides,
      ) in enumerate(
          zip(
              cls_score_list,
              bbox_pred_list,
              score_factor_list,
              param_pred_list,
              mlvl_points,
              mlvl_strides,
          )
      ):
          assert cls_score.size()[-2:] == bbox_pred.size()[-2:]
  
          dim = self.bbox_coder.encode_size
          bbox_pred = bbox_pred.permute(1, 2, 0).reshape(-1, dim)
          if with_score_factors:
              score_factor = (
                  score_factor.permute(1, 2, 0).reshape(-1).sigmoid()
              )
          cls_score = cls_score.permute(1, 2, 0).reshape(
              -1, self.cls_out_channels
          )
          if self.use_sigmoid_cls:
              scores = cls_score.sigmoid()
          else:
              # remind that we set FG labels to [0, num_class-1]
              # since mmdet v2.0
              # BG cat_id: num_class
              scores = cls_score.softmax(-1)[:, :-1]
  
          param_pred = param_pred.permute(1, 2, 0).reshape(
              -1, self.num_params
          )
  
          # After https://github.com/open-mmlab/mmdetection/pull/6268/,
          # this operation keeps fewer bboxes under the same `nms_pre`.
          # There is no difference in performance for most models. If you
          # find a slight drop in performance, you can set a larger
          # `nms_pre` than before.
          score_thr = cfg.get("score_thr", 0)
  
          results = filter_scores_and_topk(
              scores,
              score_thr,
              nms_pre,
              dict(
                  bbox_pred=bbox_pred,
                  param_pred=param_pred,
                  points=points,
                  strides=strides,
              ),
          )
          scores, labels, keep_idxs, filtered_results = results
  
          bbox_pred = filtered_results["bbox_pred"]
          param_pred = filtered_results["param_pred"]
          points = filtered_results["points"]
          strides = filtered_results["strides"]
  
          if with_score_factors:
              score_factor = score_factor[keep_idxs]
  
          mlvl_bbox_preds.append(bbox_pred)
          mlvl_param_preds.append(param_pred)
          mlvl_valid_points.append(points)
          mlvl_valid_strides.append(strides)
          mlvl_scores.append(scores)
          mlvl_labels.append(labels)
  
          if with_score_factors:
              mlvl_score_factors.append(score_factor)
  
      bbox_pred = torch.cat(mlvl_bbox_preds)
      priors = cat_boxes(mlvl_valid_points)
      bboxes = self.bbox_coder.decode(
          priors, bbox_pred, max_shape=img_shape
      )
  
      results = InstanceData()
      results.bboxes = bboxes
      results.scores = torch.cat(mlvl_scores)
      results.labels = torch.cat(mlvl_labels)
      results.param_preds = torch.cat(mlvl_param_preds)
      results.points = torch.cat(mlvl_valid_points)
      results.strides = torch.cat(mlvl_valid_strides)
      if with_score_factors:
          results.score_factors = torch.cat(mlvl_score_factors)
  
      return self._bbox_post_process(
          results=results,
          cfg=cfg,
          rescale=rescale,
          with_nms=with_nms,
          img_meta=img_meta,
      )
  
imports: import copy
  from typing import Dict, List, Optional, Tuple
  import torch
  import torch.nn
  import torch.nn.functional
  from mmcv.cnn import ConvModule, Scale
  from mmengine.config import ConfigDict
  from mmengine.model import BaseModule, kaiming_init
  from mmengine.structures import InstanceData
  from torch import Tensor
  from mmdet.registry import MODELS
  from mmdet.structures.bbox import cat_boxes
  from mmdet.utils import ConfigType, InstanceList, MultiConfig, OptConfigType, OptInstanceList, reduce_mean
  from ..task_modules.prior_generators import MlvlPointGenerator
  from ..utils import aligned_bilinear, filter_scores_and_topk, multi_apply, relative_coordinate_maps, select_single_mlvl
  from ..utils.misc import empty_instances
  from .base_mask_head import BaseMaskHead
  from .fcos_head import FCOSHead
label_desc: Use image node_id 9 for calling the CondInstBboxHead obj's underlying member method code with example usage: obj._predict_by_feat_single(cls_score_list, bbox_pred_list, score_factor_list, param_pred_list, mlvl_points, mlvl_strides, img_meta, cfg, rescale, with_nms) and returns: self