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: Forward feature of a single level.
  
  Args:
      x (Tensor): Feature of a single level.
      lvl_ind (int): Level index of current feature.
      return_pool (bool): Return corner pool feature or not.
  
  Returns:
      tuple[Tensor]: A tuple of CornerHead's output for current feature
      level. Containing the following Tensors:
  
          - tl_heat (Tensor): Predicted top-left corner heatmap.
          - br_heat (Tensor): Predicted bottom-right corner heatmap.
          - tl_emb (Tensor | None): Predicted top-left embedding heatmap.
            None for `self.with_corner_emb == False`.
          - br_emb (Tensor | None): Predicted bottom-right embedding
            heatmap. None for `self.with_corner_emb == False`.
          - tl_off (Tensor): Predicted top-left offset heatmap.
          - br_off (Tensor): Predicted bottom-right offset heatmap.
          - tl_pool (Tensor): Top-left corner pool feature. Not must
            have.
          - br_pool (Tensor): Bottom-right corner pool feature. Not must
            have.
docstr_tok: ["Forward","feature","of","a","single","level",".","Args",":","x","(","Tensor",")",":","Feature","of","a","single","level",".","lvl_ind","(","int",")",":","Level","index","of","current","feature",".","return_pool","(","bool",")",":","Return","corner","pool","feature","or","not",".","Returns",":","tuple","[","Tensor","]",":","A","tuple","of","CornerHead","'s","output","for","current","feature","level",".","Containing","the","following","Tensors",":","-","tl_heat","(","Tensor",")",":","Predicted","top-left","corner","heatmap",".","-","br_heat","(","Tensor",")",":","Predicted","bottom-right","corner","heatmap",".","-","tl_emb","(","Tensor","|","None",")",":","Predicted","top-left","embedding","heatmap",".","None","for","`","self.with_corner_emb","==","False","`",".","-","br_emb","(","Tensor","|","None",")",":","Predicted","bottom-right","embedding","heatmap",".","None","for","`","self.with_corner_emb","==","False","`",".","-","tl_off","(","Tensor",")",":","Predicted","top-left","offset","heatmap",".","-","br_off","(","Tensor",")",":","Predicted","bottom-right","offset","heatmap",".","-","tl_pool","(","Tensor",")",":","Top-left","corner","pool","feature",".","Not","must","have",".","-","br_pool","(","Tensor",")",":","Bottom-right","corner","pool","feature",".","Not","must","have","."]
code: def forward_single(self, x, lvl_ind, return_pool=False):
      """Forward feature of a single level.
  
      Args:
          x (Tensor): Feature of a single level.
          lvl_ind (int): Level index of current feature.
          return_pool (bool): Return corner pool feature or not.
  
      Returns:
          tuple[Tensor]: A tuple of CornerHead's output for current feature
          level. Containing the following Tensors:
  
              - tl_heat (Tensor): Predicted top-left corner heatmap.
              - br_heat (Tensor): Predicted bottom-right corner heatmap.
              - tl_emb (Tensor | None): Predicted top-left embedding heatmap.
                None for `self.with_corner_emb == False`.
              - br_emb (Tensor | None): Predicted bottom-right embedding
                heatmap. None for `self.with_corner_emb == False`.
              - tl_off (Tensor): Predicted top-left offset heatmap.
              - br_off (Tensor): Predicted bottom-right offset heatmap.
              - tl_pool (Tensor): Top-left corner pool feature. Not must
                have.
              - br_pool (Tensor): Bottom-right corner pool feature. Not must
                have.
      """
      tl_pool = self.tl_pool[lvl_ind](x)
      tl_heat = self.tl_heat[lvl_ind](tl_pool)
      br_pool = self.br_pool[lvl_ind](x)
      br_heat = self.br_heat[lvl_ind](br_pool)
  
      tl_emb, br_emb = None, None
      if self.with_corner_emb:
          tl_emb = self.tl_emb[lvl_ind](tl_pool)
          br_emb = self.br_emb[lvl_ind](br_pool)
  
      tl_off = self.tl_off[lvl_ind](tl_pool)
      br_off = self.br_off[lvl_ind](br_pool)
  
      result_list = [tl_heat, br_heat, tl_emb, br_emb, tl_off, br_off]
      if return_pool:
          result_list.append(tl_pool)
          result_list.append(br_pool)
  
      return result_list
  
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 8 for calling the CornerHead obj's underlying member method code with example usage: obj.forward_single(x, lvl_ind, return_pool) and returns: result_list