class_docstr: Head of CornerNet: Detecting Objects as Paired Keypoints.
  
  Code is modified from the `official github repo
  <https://github.com/princeton-vl/CornerNet/blob/master/models/py_utils/
  kp.py#L73>`_ .
  
  More details can be found in the `paper
  <https://arxiv.org/abs/1808.01244>`_ .
  
  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. Because
          HourglassNet-104 outputs the final feature and intermediate
          supervision feature and HourglassNet-52 only outputs the final
          feature. Default: 2.
      corner_emb_channels (int): Channel of embedding vector. Default: 1.
      train_cfg (dict | None): Training config. Useless in CornerHead,
          but we keep this variable for SingleStageDetector. Default: None.
      test_cfg (dict | None): Testing config of CornerHead. Default: None.
      loss_heatmap (dict | None): Config of corner heatmap loss. Default:
          GaussianFocalLoss.
      loss_embedding (dict | None): Config of corner embedding loss. Default:
          AssociativeEmbeddingLoss.
      loss_offset (dict | None): Config of corner offset loss. Default:
          SmoothL1Loss.
class_docstr_tok: ["Head","of","CornerNet",":","Detecting","Objects","as","Paired","Keypoints",".","Code","is","modified","from","the","`","official","github","repo","<","https",":","\/\/github.com\/princeton-vl\/CornerNet\/blob\/master\/models\/py_utils\/","kp.py","#","L73",">","`","_",".","More","details","can","be","found","in","the","`","paper","<","https",":","\/\/arxiv.org\/abs\/1808.01244",">","`","_",".","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",".","Because","HourglassNet-104","outputs","the","final","feature","and","intermediate","supervision","feature","and","HourglassNet-52","only","outputs","the","final","feature",".","Default",":","2.","corner_emb_channels","(","int",")",":","Channel","of","embedding","vector",".","Default",":","1.","train_cfg","(","dict","|","None",")",":","Training","config",".","Useless","in","CornerHead",",","but","we","keep","this","variable","for","SingleStageDetector",".","Default",":","None",".","test_cfg","(","dict","|","None",")",":","Testing","config","of","CornerHead",".","Default",":","None",".","loss_heatmap","(","dict","|","None",")",":","Config","of","corner","heatmap","loss",".","Default",":","GaussianFocalLoss",".","loss_embedding","(","dict","|","None",")",":","Config","of","corner","embedding","loss",".","Default",":","AssociativeEmbeddingLoss",".","loss_offset","(","dict","|","None",")",":","Config","of","corner","offset","loss",".","Default",":","SmoothL1Loss","."]
docstr: Transform outputs for a single batch item into bbox predictions.
  
  Args:
      tl_heat (Tensor): Top-left corner heatmap for current level with
          shape (N, num_classes, H, W).
      br_heat (Tensor): Bottom-right corner heatmap for current level
          with shape (N, num_classes, H, W).
      tl_off (Tensor): Top-left corner offset for current level with
          shape (N, corner_offset_channels, H, W).
      br_off (Tensor): Bottom-right corner offset for current level with
          shape (N, corner_offset_channels, H, W).
      img_meta (dict): Meta information of current image, e.g.,
          image size, scaling factor, etc.
      tl_emb (Tensor): Top-left corner embedding for current level with
          shape (N, corner_emb_channels, H, W).
      br_emb (Tensor): Bottom-right corner embedding for current level
          with shape (N, corner_emb_channels, H, W).
      tl_centripetal_shift: Top-left corner's centripetal shift for
          current level with shape (N, 2, H, W).
      br_centripetal_shift: Bottom-right corner's centripetal shift for
          current level with shape (N, 2, H, W).
      rescale (bool): If True, return boxes in original image space.
          Default: False.
      with_nms (bool): If True, do nms before return boxes.
          Default: True.
docstr_tok: ["Transform","outputs","for","a","single","batch","item","into","bbox","predictions",".","Args",":","tl_heat","(","Tensor",")",":","Top-left","corner","heatmap","for","current","level","with","shape","(","N",",","num_classes",",","H",",","W",")",".","br_heat","(","Tensor",")",":","Bottom-right","corner","heatmap","for","current","level","with","shape","(","N",",","num_classes",",","H",",","W",")",".","tl_off","(","Tensor",")",":","Top-left","corner","offset","for","current","level","with","shape","(","N",",","corner_offset_channels",",","H",",","W",")",".","br_off","(","Tensor",")",":","Bottom-right","corner","offset","for","current","level","with","shape","(","N",",","corner_offset_channels",",","H",",","W",")",".","img_meta","(","dict",")",":","Meta","information","of","current","image",",","e.g.",",","image","size",",","scaling","factor",",","etc",".","tl_emb","(","Tensor",")",":","Top-left","corner","embedding","for","current","level","with","shape","(","N",",","corner_emb_channels",",","H",",","W",")",".","br_emb","(","Tensor",")",":","Bottom-right","corner","embedding","for","current","level","with","shape","(","N",",","corner_emb_channels",",","H",",","W",")",".","tl_centripetal_shift",":","Top-left","corner","'s","centripetal","shift","for","current","level","with","shape","(","N",",","2",",","H",",","W",")",".","br_centripetal_shift",":","Bottom-right","corner","'s","centripetal","shift","for","current","level","with","shape","(","N",",","2",",","H",",","W",")",".","rescale","(","bool",")",":","If","True",",","return","boxes","in","original","image","space",".","Default",":","False",".","with_nms","(","bool",")",":","If","True",",","do","nms","before","return","boxes",".","Default",":","True","."]
code: def _get_bboxes_single(
      self,
      tl_heat,
      br_heat,
      tl_off,
      br_off,
      img_meta,
      tl_emb=None,
      br_emb=None,
      tl_centripetal_shift=None,
      br_centripetal_shift=None,
      rescale=False,
      with_nms=True,
  ):
      """Transform outputs for a single batch item into bbox predictions.
  
      Args:
          tl_heat (Tensor): Top-left corner heatmap for current level with
              shape (N, num_classes, H, W).
          br_heat (Tensor): Bottom-right corner heatmap for current level
              with shape (N, num_classes, H, W).
          tl_off (Tensor): Top-left corner offset for current level with
              shape (N, corner_offset_channels, H, W).
          br_off (Tensor): Bottom-right corner offset for current level with
              shape (N, corner_offset_channels, H, W).
          img_meta (dict): Meta information of current image, e.g.,
              image size, scaling factor, etc.
          tl_emb (Tensor): Top-left corner embedding for current level with
              shape (N, corner_emb_channels, H, W).
          br_emb (Tensor): Bottom-right corner embedding for current level
              with shape (N, corner_emb_channels, H, W).
          tl_centripetal_shift: Top-left corner's centripetal shift for
              current level with shape (N, 2, H, W).
          br_centripetal_shift: Bottom-right corner's centripetal shift for
              current level with shape (N, 2, H, W).
          rescale (bool): If True, return boxes in original image space.
              Default: False.
          with_nms (bool): If True, do nms before return boxes.
              Default: True.
      """
      if isinstance(img_meta, (list, tuple)):
          img_meta = img_meta[0]
  
      batch_bboxes, batch_scores, batch_clses = self.decode_heatmap(
          tl_heat=tl_heat.sigmoid(),
          br_heat=br_heat.sigmoid(),
          tl_off=tl_off,
          br_off=br_off,
          tl_emb=tl_emb,
          br_emb=br_emb,
          tl_centripetal_shift=tl_centripetal_shift,
          br_centripetal_shift=br_centripetal_shift,
          img_meta=img_meta,
          k=self.test_cfg.corner_topk,
          kernel=self.test_cfg.local_maximum_kernel,
          distance_threshold=self.test_cfg.distance_threshold,
      )
  
      if rescale:
          batch_bboxes /= img_meta["scale_factor"]
  
      bboxes = batch_bboxes.view([-1, 4])
      scores = batch_scores.view([-1, 1])
      clses = batch_clses.view([-1, 1])
  
      idx = scores.argsort(dim=0, descending=True)
      bboxes = bboxes[idx].view([-1, 4])
      scores = scores[idx].view(-1)
      clses = clses[idx].view(-1)
  
      detections = torch.cat([bboxes, scores.unsqueeze(-1)], -1)
      keepinds = detections[:, -1] > -0.1
      detections = detections[keepinds]
      labels = clses[keepinds]
  
      if with_nms:
          detections, labels = self._bboxes_nms(
              detections, labels, self.test_cfg
          )
  
      return detections, labels
  
imports: from math import ceil, log
  import torch
  import torch.nn
  import torch.nn.functional
  from mmcv.cnn import ConvModule, bias_init_with_prob
  from mmcv.ops import CornerPool, batched_nms
  from mmdet.core import multi_apply
  from ..builder import HEADS, build_loss
  from ..utils import gaussian_radius, gen_gaussian_target
  from .base_dense_head import BaseDenseHead
label_desc: Use image node_id 13 for calling the CornerHead obj's underlying member method code with example usage: obj._get_bboxes_single(tl_heat, br_heat, tl_off, br_off, img_meta, tl_emb, br_emb, tl_centripetal_shift, br_centripetal_shift, rescale, with_nms) and returns: detections,  labels