class_docstr: Head of `End-to-End Multi-Person Pose Estimation with Transformers`.
  
  Args:
      num_classes (int): Number of categories excluding the background.
      in_channels (int): Number of channels in the input feature map.
      num_query (int): Number of query in Transformer.
      num_kpt_fcs (int, optional): Number of fully-connected layers used in
          `FFN`, which is then used for the keypoint regression head.
          Default 2.
      transformer (obj:`mmcv.ConfigDict`|dict): ConfigDict is used for
          building the Encoder and Decoder. Default: None.
      sync_cls_avg_factor (bool): Whether to sync the avg_factor of
          all ranks. Default to False.
      positional_encoding (obj:`mmcv.ConfigDict`|dict):
          Config for position encoding.
      loss_cls (obj:`mmcv.ConfigDict`|dict): Config of the
          classification loss. Default `CrossEntropyLoss`.
      loss_kpt (obj:`mmcv.ConfigDict`|dict): Config of the
          regression loss. Default `L1Loss`.
      loss_oks (obj:`mmcv.ConfigDict`|dict): Config of the
          regression oks loss. Default `OKSLoss`.
      loss_hm (obj:`mmcv.ConfigDict`|dict): Config of the
          regression heatmap loss. Default `NegLoss`.
      as_two_stage (bool) : Whether to generate the proposal from
          the outputs of encoder.
      with_kpt_refine (bool): Whether to refine the reference points
          in the decoder. Defaults to True.
      test_cfg (obj:`mmcv.ConfigDict`|dict): Testing config of
          transformer head.
      init_cfg (dict or list[dict], optional): Initialization config dict.
          Default: None.
class_docstr_tok: ["Head","of","`","End-to-End","Multi-Person","Pose","Estimation","with","Transformers","`",".","Args",":","num_classes","(","int",")",":","Number","of","categories","excluding","the","background",".","in_channels","(","int",")",":","Number","of","channels","in","the","input","feature","map",".","num_query","(","int",")",":","Number","of","query","in","Transformer",".","num_kpt_fcs","(","int",",","optional",")",":","Number","of","fully-connected","layers","used","in","`","FFN","`",",","which","is","then","used","for","the","keypoint","regression","head",".","Default","2.","transformer","(","obj",":","`","mmcv.ConfigDict","`","|dict",")",":","ConfigDict","is","used","for","building","the","Encoder","and","Decoder",".","Default",":","None",".","sync_cls_avg_factor","(","bool",")",":","Whether","to","sync","the","avg_factor","of","all","ranks",".","Default","to","False",".","positional_encoding","(","obj",":","`","mmcv.ConfigDict","`","|dict",")",":","Config","for","position","encoding",".","loss_cls","(","obj",":","`","mmcv.ConfigDict","`","|dict",")",":","Config","of","the","classification","loss",".","Default","`","CrossEntropyLoss","`",".","loss_kpt","(","obj",":","`","mmcv.ConfigDict","`","|dict",")",":","Config","of","the","regression","loss",".","Default","`","L1Loss","`",".","loss_oks","(","obj",":","`","mmcv.ConfigDict","`","|dict",")",":","Config","of","the","regression","oks","loss",".","Default","`","OKSLoss","`",".","loss_hm","(","obj",":","`","mmcv.ConfigDict","`","|dict",")",":","Config","of","the","regression","heatmap","loss",".","Default","`","NegLoss","`",".","as_two_stage","(","bool",")",":","Whether","to","generate","the","proposal","from","the","outputs","of","encoder",".","with_kpt_refine","(","bool",")",":","Whether","to","refine","the","reference","points","in","the","decoder",".","Defaults","to","True",".","test_cfg","(","obj",":","`","mmcv.ConfigDict","`","|dict",")",":","Testing","config","of","transformer","head",".","init_cfg","(","dict","or","list","[","dict","]",",","optional",")",":","Initialization","config","dict",".","Default",":","None","."]
code: def loss_heatmap(
      self, hm_pred, hm_mask, gt_keypoints, gt_labels, gt_bboxes
  ):
      assert hm_pred.shape[-2:] == hm_mask.shape[-2:]
      num_img, _, h, w = hm_pred.shape
      # placeholder of heatmap target (Gaussian distribution)
      hm_target = paddle.zeros(hm_pred.shape, hm_pred.dtype)
      for i, (gt_label, gt_bbox, gt_keypoint) in enumerate(
          zip(gt_labels, gt_bboxes, gt_keypoints)
      ):
          if gt_label.shape[0] == 0:
              continue
          gt_keypoint = gt_keypoint.reshape(
              (gt_keypoint.shape[0], -1, 3)
          ).clone()
          gt_keypoint[..., :2] /= 8
  
          assert (
              gt_keypoint[..., 0].max() <= w + 0.5
          )  # new coordinate system
          assert (
              gt_keypoint[..., 1].max() <= h + 0.5
          )  # new coordinate system
          gt_bbox /= 8
          gt_w = gt_bbox[:, 2] - gt_bbox[:, 0]
          gt_h = gt_bbox[:, 3] - gt_bbox[:, 1]
          for j in range(gt_label.shape[0]):
              # get heatmap radius
              kp_radius = paddle.clip(
                  paddle.floor(
                      gaussian_radius(
                          (gt_h[j], gt_w[j]), min_overlap=0.9
                      )
                  ),
                  min=0,
                  max=3,
              )
              for k in range(self.num_keypoints):
                  if gt_keypoint[j, k, 2] > 0:
                      gt_kp = gt_keypoint[j, k, :2]
                      gt_kp_int = paddle.floor(gt_kp)
                      hm_target[i, k] = draw_umich_gaussian(
                          hm_target[i, k], gt_kp_int, kp_radius
                      )
      # compute heatmap loss
      hm_pred = paddle.clip(
          F.sigmoid(hm_pred), min=1e-4, max=1 - 1e-4
      )  # refer to CenterNet
      loss_hm = self.loss_hm(
          hm_pred,
          hm_target.detach(),
          mask=~hm_mask.astype("bool").unsqueeze(1),
      )
      return loss_hm
  
imports: import copy
  import numpy
  import paddle
  import paddle.nn
  import paddle.nn.functional
  from ppdet.core.workspace import register
  import paddle.distributed
  from ..transformers.petr_transformer import inverse_sigmoid, masked_fill
  from ..initializer import constant_, normal_
  from functools import partial
label_desc: Use image node_id 8 for calling the PETRHead obj's underlying member method code with example usage: obj.loss_heatmap(hm_pred, hm_mask, gt_keypoints, gt_labels, gt_bboxes) and returns: loss_hm