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 batch of output features extracted from the head into
  bbox results.
  
  Note: When score_factors is not None, the cls_scores are
  usually multiplied by it then obtain the real score used in NMS,
  such as CenterNess in FCOS, IoU branch in ATSS.
  
  Args:
      cls_scores (list[Tensor]): Classification scores for all
          scale levels, each is a 4D-tensor, has shape
          (batch_size, num_priors * num_classes, H, W).
      bbox_preds (list[Tensor]): Box energies / deltas for all
          scale levels, each is a 4D-tensor, has shape
          (batch_size, num_priors * 4, H, W).
      score_factors (list[Tensor], optional): Score factor for
          all scale level, each is a 4D-tensor, has shape
          (batch_size, num_priors * 1, H, W). Defaults to None.
      param_preds (list[Tensor], optional): Params for all scale
          level, each is a 4D-tensor, has shape
          (batch_size, num_priors * num_params, H, W)
      batch_img_metas (list[dict], Optional): Batch image meta info.
          Defaults to None.
      cfg (ConfigDict, optional): Test / postprocessing
          configuration, if None, test_cfg would be used.
          Defaults to None.
      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:
      list[:obj:`InstanceData`]: Object 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","batch","of","output","features","extracted","from","the","head","into","bbox","results",".","Note",":","When","score_factors","is","not","None",",","the","cls_scores","are","usually","multiplied","by","it","then","obtain","the","real","score","used","in","NMS",",","such","as","CenterNess","in","FCOS",",","IoU","branch","in","ATSS",".","Args",":","cls_scores","(","list","[","Tensor","]",")",":","Classification","scores","for","all","scale","levels",",","each","is","a","4D-tensor",",","has","shape","(","batch_size",",","num_priors","*","num_classes",",","H",",","W",")",".","bbox_preds","(","list","[","Tensor","]",")",":","Box","energies","\/","deltas","for","all","scale","levels",",","each","is","a","4D-tensor",",","has","shape","(","batch_size",",","num_priors","*","4",",","H",",","W",")",".","score_factors","(","list","[","Tensor","]",",","optional",")",":","Score","factor","for","all","scale","level",",","each","is","a","4D-tensor",",","has","shape","(","batch_size",",","num_priors","*","1",",","H",",","W",")",".","Defaults","to","None",".","param_preds","(","list","[","Tensor","]",",","optional",")",":","Params","for","all","scale","level",",","each","is","a","4D-tensor",",","has","shape","(","batch_size",",","num_priors","*","num_params",",","H",",","W",")","batch_img_metas","(","list","[","dict","]",",","Optional",")",":","Batch","image","meta","info",".","Defaults","to","None",".","cfg","(","ConfigDict",",","optional",")",":","Test","\/","postprocessing","configuration",",","if","None",",","test_cfg","would","be","used",".","Defaults","to","None",".","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",":","list","[",":","obj",":","`","InstanceData","`","]",":","Object","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(
      self,
      cls_scores: List[Tensor],
      bbox_preds: List[Tensor],
      score_factors: Optional[List[Tensor]] = None,
      param_preds: Optional[List[Tensor]] = None,
      batch_img_metas: Optional[List[dict]] = None,
      cfg: Optional[ConfigDict] = None,
      rescale: bool = False,
      with_nms: bool = True,
  ) -> InstanceList:
      """Transform a batch of output features extracted from the head into
      bbox results.
  
      Note: When score_factors is not None, the cls_scores are
      usually multiplied by it then obtain the real score used in NMS,
      such as CenterNess in FCOS, IoU branch in ATSS.
  
      Args:
          cls_scores (list[Tensor]): Classification scores for all
              scale levels, each is a 4D-tensor, has shape
              (batch_size, num_priors * num_classes, H, W).
          bbox_preds (list[Tensor]): Box energies / deltas for all
              scale levels, each is a 4D-tensor, has shape
              (batch_size, num_priors * 4, H, W).
          score_factors (list[Tensor], optional): Score factor for
              all scale level, each is a 4D-tensor, has shape
              (batch_size, num_priors * 1, H, W). Defaults to None.
          param_preds (list[Tensor], optional): Params for all scale
              level, each is a 4D-tensor, has shape
              (batch_size, num_priors * num_params, H, W)
          batch_img_metas (list[dict], Optional): Batch image meta info.
              Defaults to None.
          cfg (ConfigDict, optional): Test / postprocessing
              configuration, if None, test_cfg would be used.
              Defaults to None.
          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:
          list[:obj:`InstanceData`]: Object 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).
      """
      assert len(cls_scores) == len(bbox_preds)
  
      if score_factors is None:
          # e.g. Retina, FreeAnchor, Foveabox, etc.
          with_score_factors = False
      else:
          # e.g. FCOS, PAA, ATSS, AutoAssign, etc.
          with_score_factors = True
          assert len(cls_scores) == len(score_factors)
  
      num_levels = len(cls_scores)
  
      featmap_sizes = [
          cls_scores[i].shape[-2:] for i in range(num_levels)
      ]
      all_level_points_strides = self.prior_generator.grid_priors(
          featmap_sizes,
          dtype=bbox_preds[0].dtype,
          device=bbox_preds[0].device,
          with_stride=True,
      )
      all_level_points = [i[:, :2] for i in all_level_points_strides]
      all_level_strides = [i[:, 2] for i in all_level_points_strides]
  
      result_list = []
  
      for img_id in range(len(batch_img_metas)):
          img_meta = batch_img_metas[img_id]
          cls_score_list = select_single_mlvl(
              cls_scores, img_id, detach=True
          )
          bbox_pred_list = select_single_mlvl(
              bbox_preds, img_id, detach=True
          )
          if with_score_factors:
              score_factor_list = select_single_mlvl(
                  score_factors, img_id, detach=True
              )
          else:
              score_factor_list = [None for _ in range(num_levels)]
          param_pred_list = select_single_mlvl(
              param_preds, img_id, detach=True
          )
  
          results = self._predict_by_feat_single(
              cls_score_list=cls_score_list,
              bbox_pred_list=bbox_pred_list,
              score_factor_list=score_factor_list,
              param_pred_list=param_pred_list,
              mlvl_points=all_level_points,
              mlvl_strides=all_level_strides,
              img_meta=img_meta,
              cfg=cfg,
              rescale=rescale,
              with_nms=with_nms,
          )
          result_list.append(results)
      return result_list
  
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 8 for calling the CondInstBboxHead obj's underlying member method code with example usage: obj.predict_by_feat(cls_scores, bbox_preds, score_factors, param_preds, batch_img_metas, cfg, rescale, with_nms) and returns: result_list