class_docstr: Head of CentripetalNet: Pursuing High-quality Keypoint Pairs for Object
  Detection.
  
  CentripetalHead inherits from :class:`CornerHead`. It removes the
  embedding branch and adds guiding shift and centripetal shift branches.
  More details can be found in the `paper
  <https://arxiv.org/abs/2003.09119>`_ .
  
  Args:
      num_classes (int): Number of categories excluding the background
          category.
      in_channels (int): Number of channels in the input feature map.
      num_feat_levels (int): Levels of feature from the previous module.
          2 for HourglassNet-104 and 1 for HourglassNet-52. HourglassNet-104
          outputs the final feature and intermediate supervision feature and
          HourglassNet-52 only outputs the final feature. Defaults to 2.
      corner_emb_channels (int): Channel of embedding vector. Defaults to 1.
      train_cfg (:obj:`ConfigDict` or dict, optional): Training config.
          Useless in CornerHead, but we keep this variable for
          SingleStageDetector.
      test_cfg (:obj:`ConfigDict` or dict, optional): Testing config of
          CornerHead.
      loss_heatmap (:obj:`ConfigDict` or dict): Config of corner heatmap
          loss. Defaults to GaussianFocalLoss.
      loss_embedding (:obj:`ConfigDict` or dict): Config of corner embedding
          loss. Defaults to AssociativeEmbeddingLoss.
      loss_offset (:obj:`ConfigDict` or dict): Config of corner offset loss.
          Defaults to SmoothL1Loss.
      loss_guiding_shift (:obj:`ConfigDict` or dict): Config of
          guiding shift loss. Defaults to SmoothL1Loss.
      loss_centripetal_shift (:obj:`ConfigDict` or dict): Config of
          centripetal shift loss. Defaults to SmoothL1Loss.
     init_cfg (:obj:`ConfigDict` or dict, optional): the config to control
         the initialization.
class_docstr_tok: ["Head","of","CentripetalNet",":","Pursuing","High-quality","Keypoint","Pairs","for","Object","Detection",".","CentripetalHead","inherits","from",":","class",":","`","CornerHead","`",".","It","removes","the","embedding","branch","and","adds","guiding","shift","and","centripetal","shift","branches",".","More","details","can","be","found","in","the","`","paper","<","https",":","\/\/arxiv.org\/abs\/2003.09119",">","`","_",".","Args",":","num_classes","(","int",")",":","Number","of","categories","excluding","the","background","category",".","in_channels","(","int",")",":","Number","of","channels","in","the","input","feature","map",".","num_feat_levels","(","int",")",":","Levels","of","feature","from","the","previous","module",".","2","for","HourglassNet-104","and","1","for","HourglassNet-52",".","HourglassNet-104","outputs","the","final","feature","and","intermediate","supervision","feature","and","HourglassNet-52","only","outputs","the","final","feature",".","Defaults","to","2.","corner_emb_channels","(","int",")",":","Channel","of","embedding","vector",".","Defaults","to","1.","train_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","optional",")",":","Training","config",".","Useless","in","CornerHead",",","but","we","keep","this","variable","for","SingleStageDetector",".","test_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","optional",")",":","Testing","config","of","CornerHead",".","loss_heatmap","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","corner","heatmap","loss",".","Defaults","to","GaussianFocalLoss",".","loss_embedding","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","corner","embedding","loss",".","Defaults","to","AssociativeEmbeddingLoss",".","loss_offset","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","corner","offset","loss",".","Defaults","to","SmoothL1Loss",".","loss_guiding_shift","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","guiding","shift","loss",".","Defaults","to","SmoothL1Loss",".","loss_centripetal_shift","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","centripetal","shift","loss",".","Defaults","to","SmoothL1Loss",".","init_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","optional",")",":","the","config","to","control","the","initialization","."]
docstr: Transform a batch of output features extracted from the head into
  bbox results.
  
  Args:
      tl_heats (list[Tensor]): Top-left corner heatmaps for each level
          with shape (N, num_classes, H, W).
      br_heats (list[Tensor]): Bottom-right corner heatmaps for each
          level with shape (N, num_classes, H, W).
      tl_offs (list[Tensor]): Top-left corner offsets for each level
          with shape (N, corner_offset_channels, H, W).
      br_offs (list[Tensor]): Bottom-right corner offsets for each level
          with shape (N, corner_offset_channels, H, W).
      tl_guiding_shifts (list[Tensor]): Top-left guiding shifts for each
          level with shape (N, guiding_shift_channels, H, W). Useless in
          this function, we keep this arg because it's the raw output
          from CentripetalHead.
      br_guiding_shifts (list[Tensor]): Bottom-right guiding shifts for
          each level with shape (N, guiding_shift_channels, H, W).
          Useless in this function, we keep this arg because it's the
          raw output from CentripetalHead.
      tl_centripetal_shifts (list[Tensor]): Top-left centripetal shifts
          for each level with shape (N, centripetal_shift_channels, H,
          W).
      br_centripetal_shifts (list[Tensor]): Bottom-right centripetal
          shifts for each level with shape (N,
          centripetal_shift_channels, H, W).
      batch_img_metas (list[dict], optional): Batch image meta info.
          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",".","Args",":","tl_heats","(","list","[","Tensor","]",")",":","Top-left","corner","heatmaps","for","each","level","with","shape","(","N",",","num_classes",",","H",",","W",")",".","br_heats","(","list","[","Tensor","]",")",":","Bottom-right","corner","heatmaps","for","each","level","with","shape","(","N",",","num_classes",",","H",",","W",")",".","tl_offs","(","list","[","Tensor","]",")",":","Top-left","corner","offsets","for","each","level","with","shape","(","N",",","corner_offset_channels",",","H",",","W",")",".","br_offs","(","list","[","Tensor","]",")",":","Bottom-right","corner","offsets","for","each","level","with","shape","(","N",",","corner_offset_channels",",","H",",","W",")",".","tl_guiding_shifts","(","list","[","Tensor","]",")",":","Top-left","guiding","shifts","for","each","level","with","shape","(","N",",","guiding_shift_channels",",","H",",","W",")",".","Useless","in","this","function",",","we","keep","this","arg","because","it","'s","the","raw","output","from","CentripetalHead",".","br_guiding_shifts","(","list","[","Tensor","]",")",":","Bottom-right","guiding","shifts","for","each","level","with","shape","(","N",",","guiding_shift_channels",",","H",",","W",")",".","Useless","in","this","function",",","we","keep","this","arg","because","it","'s","the","raw","output","from","CentripetalHead",".","tl_centripetal_shifts","(","list","[","Tensor","]",")",":","Top-left","centripetal","shifts","for","each","level","with","shape","(","N",",","centripetal_shift_channels",",","H",",","W",")",".","br_centripetal_shifts","(","list","[","Tensor","]",")",":","Bottom-right","centripetal","shifts","for","each","level","with","shape","(","N",",","centripetal_shift_channels",",","H",",","W",")",".","batch_img_metas","(","list","[","dict","]",",","optional",")",":","Batch","image","meta","info",".","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,
      tl_heats: List[Tensor],
      br_heats: List[Tensor],
      tl_offs: List[Tensor],
      br_offs: List[Tensor],
      tl_guiding_shifts: List[Tensor],
      br_guiding_shifts: List[Tensor],
      tl_centripetal_shifts: List[Tensor],
      br_centripetal_shifts: List[Tensor],
      batch_img_metas: Optional[List[dict]] = None,
      rescale: bool = False,
      with_nms: bool = True,
  ) -> InstanceList:
      """Transform a batch of output features extracted from the head into
      bbox results.
  
      Args:
          tl_heats (list[Tensor]): Top-left corner heatmaps for each level
              with shape (N, num_classes, H, W).
          br_heats (list[Tensor]): Bottom-right corner heatmaps for each
              level with shape (N, num_classes, H, W).
          tl_offs (list[Tensor]): Top-left corner offsets for each level
              with shape (N, corner_offset_channels, H, W).
          br_offs (list[Tensor]): Bottom-right corner offsets for each level
              with shape (N, corner_offset_channels, H, W).
          tl_guiding_shifts (list[Tensor]): Top-left guiding shifts for each
              level with shape (N, guiding_shift_channels, H, W). Useless in
              this function, we keep this arg because it's the raw output
              from CentripetalHead.
          br_guiding_shifts (list[Tensor]): Bottom-right guiding shifts for
              each level with shape (N, guiding_shift_channels, H, W).
              Useless in this function, we keep this arg because it's the
              raw output from CentripetalHead.
          tl_centripetal_shifts (list[Tensor]): Top-left centripetal shifts
              for each level with shape (N, centripetal_shift_channels, H,
              W).
          br_centripetal_shifts (list[Tensor]): Bottom-right centripetal
              shifts for each level with shape (N,
              centripetal_shift_channels, H, W).
          batch_img_metas (list[dict], optional): Batch image meta info.
              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 (
          tl_heats[-1].shape[0]
          == br_heats[-1].shape[0]
          == len(batch_img_metas)
      )
      result_list = []
      for img_id in range(len(batch_img_metas)):
          result_list.append(
              self._predict_by_feat_single(
                  tl_heats[-1][img_id : img_id + 1, :],
                  br_heats[-1][img_id : img_id + 1, :],
                  tl_offs[-1][img_id : img_id + 1, :],
                  br_offs[-1][img_id : img_id + 1, :],
                  batch_img_metas[img_id],
                  tl_emb=None,
                  br_emb=None,
                  tl_centripetal_shift=tl_centripetal_shifts[-1][
                      img_id : img_id + 1, :
                  ],
                  br_centripetal_shift=br_centripetal_shifts[-1][
                      img_id : img_id + 1, :
                  ],
                  rescale=rescale,
                  with_nms=with_nms,
              )
          )
  
      return result_list
  
imports: from typing import List, Optional, Tuple
  import torch.nn
  from mmcv.cnn import ConvModule
  from mmcv.ops import DeformConv2d
  from mmengine.model import normal_init
  from torch import Tensor
  from mmdet.registry import MODELS
  from mmdet.utils import ConfigType, InstanceList, OptInstanceList, OptMultiConfig
  from ..utils import multi_apply
  from .corner_head import CornerHead
label_desc: Use image node_id 8 for calling the CentripetalHead obj's underlying member method code with example usage: obj.predict_by_feat(tl_heats, br_heats, tl_offs, br_offs, tl_guiding_shifts, br_guiding_shifts, tl_centripetal_shifts, br_centripetal_shifts, batch_img_metas, rescale, with_nms) and returns: result_list