class_docstr: YOLOV3Head Paper link: https://arxiv.org/abs/1804.02767.
  
  Args:
      num_classes (int): The number of object classes (w/o background)
      in_channels (Sequence[int]): Number of input channels per scale.
      out_channels (Sequence[int]): The number of output channels per scale
          before the final 1x1 layer. Default: (1024, 512, 256).
      anchor_generator (:obj:`ConfigDict` or dict): Config dict for anchor
          generator.
      bbox_coder (:obj:`ConfigDict` or dict): Config of bounding box coder.
      featmap_strides (Sequence[int]): The stride of each scale.
          Should be in descending order. Defaults to (32, 16, 8).
      one_hot_smoother (float): Set a non-zero value to enable label-smooth
          Defaults to 0.
      conv_cfg (:obj:`ConfigDict` or dict, optional): Config dict for
          convolution layer. Defaults to None.
      norm_cfg (:obj:`ConfigDict` or dict): Dictionary to construct and
          config norm layer. Defaults to dict(type='BN', requires_grad=True).
      act_cfg (:obj:`ConfigDict` or dict): Config dict for activation layer.
          Defaults to dict(type='LeakyReLU', negative_slope=0.1).
      loss_cls (:obj:`ConfigDict` or dict): Config of classification loss.
      loss_conf (:obj:`ConfigDict` or dict): Config of confidence loss.
      loss_xy (:obj:`ConfigDict` or dict): Config of xy coordinate loss.
      loss_wh (:obj:`ConfigDict` or dict): Config of wh coordinate loss.
      train_cfg (:obj:`ConfigDict` or dict, optional): Training config of
          YOLOV3 head. Defaults to None.
      test_cfg (:obj:`ConfigDict` or dict, optional): Testing config of
          YOLOV3 head. Defaults to None.
docstr: Transform a batch of output features extracted from the head into
  bbox results. It has been accelerated since PR #5991.
  
  Args:
      pred_maps (Sequence[Tensor]): Raw predictions for a batch of
          images.
      batch_img_metas (list[dict], Optional): Batch image meta info.
          Defaults to None.
      cfg (:obj:`ConfigDict` or dict, 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",".","It","has","been","accelerated","since","PR","#","5991",".","Args",":","pred_maps","(","Sequence","[","Tensor","]",")",":","Raw","predictions","for","a","batch","of","images",".","batch_img_metas","(","list","[","dict","]",",","Optional",")",":","Batch","image","meta","info",".","Defaults","to","None",".","cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","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,
      pred_maps: Sequence[Tensor],
      batch_img_metas: Optional[List[dict]],
      cfg: OptConfigType = None,
      rescale: bool = False,
      with_nms: bool = True,
  ) -> InstanceList:
      """Transform a batch of output features extracted from the head into
      bbox results. It has been accelerated since PR #5991.
  
      Args:
          pred_maps (Sequence[Tensor]): Raw predictions for a batch of
              images.
          batch_img_metas (list[dict], Optional): Batch image meta info.
              Defaults to None.
          cfg (:obj:`ConfigDict` or dict, 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(pred_maps) == self.num_levels
      cfg = self.test_cfg if cfg is None else cfg
      cfg = copy.deepcopy(cfg)
  
      num_imgs = len(batch_img_metas)
      featmap_sizes = [pred_map.shape[-2:] for pred_map in pred_maps]
  
      mlvl_anchors = self.prior_generator.grid_priors(
          featmap_sizes, device=pred_maps[0].device
      )
      flatten_preds = []
      flatten_strides = []
      for pred, stride in zip(pred_maps, self.featmap_strides):
          pred = pred.permute(0, 2, 3, 1).reshape(
              num_imgs, -1, self.num_attrib
          )
          pred[..., :2].sigmoid_()
          flatten_preds.append(pred)
          flatten_strides.append(
              pred.new_tensor(stride).expand(pred.size(1))
          )
  
      flatten_preds = torch.cat(flatten_preds, dim=1)
      flatten_bbox_preds = flatten_preds[..., :4]
      flatten_objectness = flatten_preds[..., 4].sigmoid()
      flatten_cls_scores = flatten_preds[..., 5:].sigmoid()
      flatten_anchors = torch.cat(mlvl_anchors)
      flatten_strides = torch.cat(flatten_strides)
      flatten_bboxes = self.bbox_coder.decode(
          flatten_anchors,
          flatten_bbox_preds,
          flatten_strides.unsqueeze(-1),
      )
      results_list = []
      for bboxes, scores, objectness, img_meta in zip(
          flatten_bboxes,
          flatten_cls_scores,
          flatten_objectness,
          batch_img_metas,
      ):
          # Filtering out all predictions with conf < conf_thr
          conf_thr = cfg.get("conf_thr", -1)
          if conf_thr > 0:
              conf_inds = objectness >= conf_thr
              bboxes = bboxes[conf_inds, :]
              scores = scores[conf_inds, :]
              objectness = objectness[conf_inds]
  
          score_thr = cfg.get("score_thr", 0)
          nms_pre = cfg.get("nms_pre", -1)
          scores, labels, keep_idxs, _ = filter_scores_and_topk(
              scores, score_thr, nms_pre
          )
  
          results = InstanceData(
              scores=scores,
              labels=labels,
              bboxes=bboxes[keep_idxs],
              score_factors=objectness[keep_idxs],
          )
          results = self._bbox_post_process(
              results=results,
              cfg=cfg,
              rescale=rescale,
              with_nms=with_nms,
              img_meta=img_meta,
          )
          results_list.append(results)
      return results_list
  
imports: import copy
  import warnings
  from typing import List, Optional, Sequence, Tuple
  import torch
  import torch.nn
  import torch.nn.functional
  from mmcv.cnn import ConvModule, is_norm
  from mmengine.model import bias_init_with_prob, constant_init, normal_init
  from mmengine.structures import InstanceData
  from torch import Tensor
  from mmdet.registry import MODELS, TASK_UTILS
  from mmdet.utils import ConfigType, InstanceList, OptConfigType, OptInstanceList
  from ..task_modules.samplers import PseudoSampler
  from ..utils import filter_scores_and_topk, images_to_levels, multi_apply
  from .base_dense_head import BaseDenseHead
label_desc: Use image node_id 7 for calling the YOLOV3Head obj's underlying member method code with example usage: obj.predict_by_feat(pred_maps, batch_img_metas, cfg, rescale, with_nms) and returns: results_list