class_docstr: Head of PAAAssignment: Probabilistic Anchor Assignment with IoU
  Prediction for Object Detection.
  
  Code is modified from the `official github repo
  <https://github.com/kkhoot/PAA/blob/master/paa_core
  /modeling/rpn/paa/loss.py>`_.
  
  More details can be found in the `paper
  <https://arxiv.org/abs/2007.08103>`_ .
  
  Args:
      topk (int): Select topk samples with smallest loss in
          each level.
      score_voting (bool): Whether to use score voting in post-process.
      covariance_type : String describing the type of covariance parameters
          to be used in :class:`sklearn.mixture.GaussianMixture`.
          It must be one of:
  
          - 'full': each component has its own general covariance matrix
          - 'tied': all components share the same general covariance matrix
          - 'diag': each component has its own diagonal covariance matrix
          - 'spherical': each component has its own single variance
          Default: 'diag'. From 'full' to 'spherical', the gmm fitting
          process is faster yet the performance could be influenced. For most
          cases, 'diag' should be a good choice.
docstr: bbox post-processing method.
  
  The boxes would be rescaled to the original image scale and do
  the nms operation. Usually with_nms is False is used for aug test.
  
  Args:
      results (:obj:`InstaceData`): Detection instance results,
          each item has shape (num_bboxes, ).
      cfg (:obj:`ConfigDict` or dict): Test / postprocessing
          configuration, if None, test_cfg would be used.
      rescale (bool): If True, return boxes in original image space.
          Default: False.
      with_nms (bool): If True, do nms before return boxes.
          Default: True.
      img_meta (dict, optional): Image meta info. Defaults to None.
  
  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: ["bbox","post-processing","method",".","The","boxes","would","be","rescaled","to","the","original","image","scale","and","do","the","nms","operation",".","Usually","with_nms","is","False","is","used","for","aug","test",".","Args",":","results","(",":","obj",":","`","InstaceData","`",")",":","Detection","instance","results",",","each","item","has","shape","(","num_bboxes",",",")",".","cfg","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Test","\/","postprocessing","configuration",",","if","None",",","test_cfg","would","be","used",".","rescale","(","bool",")",":","If","True",",","return","boxes","in","original","image","space",".","Default",":","False",".","with_nms","(","bool",")",":","If","True",",","do","nms","before","return","boxes",".","Default",":","True",".","img_meta","(","dict",",","optional",")",":","Image","meta","info",".","Defaults","to","None",".","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 _bbox_post_process(
      self,
      results: InstanceData,
      cfg: ConfigType,
      rescale: bool = False,
      with_nms: bool = True,
      img_meta: Optional[dict] = None,
  ):
      """bbox post-processing method.
  
      The boxes would be rescaled to the original image scale and do
      the nms operation. Usually with_nms is False is used for aug test.
  
      Args:
          results (:obj:`InstaceData`): Detection instance results,
              each item has shape (num_bboxes, ).
          cfg (:obj:`ConfigDict` or dict): Test / postprocessing
              configuration, if None, test_cfg would be used.
          rescale (bool): If True, return boxes in original image space.
              Default: False.
          with_nms (bool): If True, do nms before return boxes.
              Default: True.
          img_meta (dict, optional): Image meta info. Defaults to None.
  
      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 rescale:
          results.bboxes /= results.bboxes.new_tensor(
              img_meta["scale_factor"]
          ).repeat((1, 2))
      # 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 = results.scores.new_zeros(results.scores.shape[0], 1)
      mlvl_scores = torch.cat([results.scores, padding], dim=1)
  
      mlvl_nms_scores = (
          mlvl_scores * results.score_factors[:, None]
      ).sqrt()
      det_bboxes, det_labels = multiclass_nms(
          results.bboxes,
          mlvl_nms_scores,
          cfg.score_thr,
          cfg.nms,
          cfg.max_per_img,
          score_factors=None,
      )
      if self.with_score_voting and len(det_bboxes) > 0:
          det_bboxes, det_labels = self.score_voting(
              det_bboxes,
              det_labels,
              results.bboxes,
              mlvl_nms_scores,
              cfg.score_thr,
          )
      nms_results = InstanceData()
      nms_results.bboxes = det_bboxes[:, :-1]
      nms_results.scores = det_bboxes[:, -1]
      nms_results.labels = det_labels
      return nms_results
  
imports: from typing import List, Optional, Tuple
  import numpy
  import torch
  from mmengine.structures import InstanceData
  from torch import Tensor
  from mmdet.registry import MODELS
  from mmdet.structures.bbox import bbox_overlaps
  from mmdet.utils import ConfigType, InstanceList, OptConfigType, OptInstanceList
  from ..layers import multiclass_nms
  from ..utils import levels_to_images, multi_apply
  from .None import ATSSHead
label_desc: Use image node_id 10 for calling the PAAHead obj's underlying member method code with example usage: obj._bbox_post_process(results, cfg, rescale, with_nms, img_meta) and returns: nms_results