class_docstr: Detection Head of `FoveaBox: Beyond Anchor-based Object Detector.
  
  <https://arxiv.org/abs/1904.03797>`_.
  
  Args:
      num_classes (int): Number of categories excluding the background
          category.
      in_channels (int): Number of channels in the input feature map.
      base_edge_list (list[int]): List of edges.
      scale_ranges (list[tuple]): Range of scales.
      sigma (float): Super parameter of ``FoveaHead``.
      with_deform (bool):  Whether use deform conv.
      deform_groups (int): Deformable conv group size.
      init_cfg (:obj:`ConfigDict` or dict or list[:obj:`ConfigDict` or             dict], optional): Initialization config dict.
class_docstr_tok: ["Detection","Head","of","`","FoveaBox",":","Beyond","Anchor-based","Object","Detector",".","<","https",":","\/\/arxiv.org\/abs\/1904.03797",">","`","_",".","Args",":","num_classes","(","int",")",":","Number","of","categories","excluding","the","background","category",".","in_channels","(","int",")",":","Number","of","channels","in","the","input","feature","map",".","base_edge_list","(","list","[","int","]",")",":","List","of","edges",".","scale_ranges","(","list","[","tuple","]",")",":","Range","of","scales",".","sigma","(","float",")",":","Super","parameter","of","``","FoveaHead","``",".","with_deform","(","bool",")",":","Whether","use","deform","conv",".","deform_groups","(","int",")",":","Deformable","conv","group","size",".","init_cfg","(",":","obj",":","`","ConfigDict","`","or","dict","or","list","[",":","obj",":","`","ConfigDict","`","or","dict","]",",","optional",")",":","Initialization","config","dict","."]
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).
      mlvl_priors (list[Tensor]): Each element in the list is
          the priors of a single level in feature pyramid, has shape
          (num_priors, 2).
      img_meta (dict): Image meta info.
      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:
      :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",")",".","mlvl_priors","(","list","[","Tensor","]",")",":","Each","element","in","the","list","is","the","priors","of","a","single","level","in","feature","pyramid",",","has","shape","(","num_priors",",","2",")",".","img_meta","(","dict",")",":","Image","meta","info",".","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",":",":","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],
      mlvl_priors: List[Tensor],
      img_meta: dict,
      cfg: Optional[ConfigDict] = None,
      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).
          mlvl_priors (list[Tensor]): Each element in the list is
              the priors of a single level in feature pyramid, has shape
              (num_priors, 2).
          img_meta (dict): Image meta info.
          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:
          :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).
      """
      cfg = self.test_cfg if cfg is None else cfg
      assert len(cls_score_list) == len(bbox_pred_list)
      img_shape = img_meta["img_shape"]
      nms_pre = cfg.get("nms_pre", -1)
  
      mlvl_bboxes = []
      mlvl_scores = []
      mlvl_labels = []
      for level_idx, (
          cls_score,
          bbox_pred,
          stride,
          base_len,
          priors,
      ) in enumerate(
          zip(
              cls_score_list,
              bbox_pred_list,
              self.strides,
              self.base_edge_list,
              mlvl_priors,
          )
      ):
          assert cls_score.size()[-2:] == bbox_pred.size()[-2:]
          bbox_pred = bbox_pred.permute(1, 2, 0).reshape(-1, 4)
  
          scores = (
              cls_score.permute(1, 2, 0)
              .reshape(-1, self.cls_out_channels)
              .sigmoid()
          )
  
          # 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.
          results = filter_scores_and_topk(
              scores,
              cfg.score_thr,
              nms_pre,
              dict(bbox_pred=bbox_pred, priors=priors),
          )
          scores, labels, _, filtered_results = results
  
          bbox_pred = filtered_results["bbox_pred"]
          priors = filtered_results["priors"]
  
          bboxes = self._bbox_decode(
              priors, bbox_pred, base_len, img_shape
          )
  
          mlvl_bboxes.append(bboxes)
          mlvl_scores.append(scores)
          mlvl_labels.append(labels)
  
      results = InstanceData()
      results.bboxes = torch.cat(mlvl_bboxes)
      results.scores = torch.cat(mlvl_scores)
      results.labels = torch.cat(mlvl_labels)
  
      return self._bbox_post_process(
          results=results,
          cfg=cfg,
          rescale=rescale,
          with_nms=with_nms,
          img_meta=img_meta,
      )
  
imports: from typing import Dict, List, Optional, Tuple
  import torch
  import torch.nn
  from mmcv.cnn import ConvModule
  from mmcv.ops import DeformConv2d
  from mmengine.config import ConfigDict
  from mmengine.model import BaseModule
  from mmengine.structures import InstanceData
  from torch import Tensor
  from mmdet.registry import MODELS
  from mmdet.utils import InstanceList, OptInstanceList, OptMultiConfig
  from ..utils import filter_scores_and_topk, multi_apply
  from .anchor_free_head import AnchorFreeHead
label_desc: Use image node_id 7 for calling the FoveaHead obj's underlying member method code with example usage: obj._predict_by_feat_single(cls_score_list, bbox_pred_list, score_factor_list, mlvl_priors, img_meta, cfg, rescale, with_nms) and returns: self