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","."]
docstr: Compute regression and classification targets for a batch image.
  
  Outputs from a single decoder layer of a single feature level are used.
  
  Args:
      cls_scores_list (list[Tensor]): Box score logits from a single
          decoder layer for each image with shape [num_query,
          cls_out_channels].
      kpt_preds_list (list[Tensor]): Sigmoid outputs from a single
          decoder layer for each image, with normalized coordinate
          (x_{i}, y_{i}) and shape [num_query, K*2].
      gt_labels_list (list[Tensor]): Ground truth class indices for each
          image with shape (num_gts, ).
      gt_keypoints_list (list[Tensor]): Ground truth keypoints for each
          image with shape (num_gts, K*3).
      gt_areas_list (list[Tensor]): Ground truth mask areas for each
          image with shape (num_gts, ).
      img_metas (list[dict]): List of image meta information.
  
  Returns:
      tuple: a tuple containing the following targets.
  
          - labels_list (list[Tensor]): Labels for all images.
          - label_weights_list (list[Tensor]): Label weights for all
              images.
          - kpt_targets_list (list[Tensor]): Keypoint targets for all
              images.
          - kpt_weights_list (list[Tensor]): Keypoint weights for all
              images.
          - area_targets_list (list[Tensor]): area targets for all
              images.
          - num_total_pos (int): Number of positive samples in all
              images.
          - num_total_neg (int): Number of negative samples in all
              images.
docstr_tok: ["Compute","regression","and","classification","targets","for","a","batch","image",".","Outputs","from","a","single","decoder","layer","of","a","single","feature","level","are","used",".","Args",":","cls_scores_list","(","list","[","Tensor","]",")",":","Box","score","logits","from","a","single","decoder","layer","for","each","image","with","shape","[","num_query",",","cls_out_channels","]",".","kpt_preds_list","(","list","[","Tensor","]",")",":","Sigmoid","outputs","from","a","single","decoder","layer","for","each","image",",","with","normalized","coordinate","(","x_","{","i","}",",","y_","{","i","}",")","and","shape","[","num_query",",","K","*","2","]",".","gt_labels_list","(","list","[","Tensor","]",")",":","Ground","truth","class","indices","for","each","image","with","shape","(","num_gts",",",")",".","gt_keypoints_list","(","list","[","Tensor","]",")",":","Ground","truth","keypoints","for","each","image","with","shape","(","num_gts",",","K","*","3",")",".","gt_areas_list","(","list","[","Tensor","]",")",":","Ground","truth","mask","areas","for","each","image","with","shape","(","num_gts",",",")",".","img_metas","(","list","[","dict","]",")",":","List","of","image","meta","information",".","Returns",":","tuple",":","a","tuple","containing","the","following","targets",".","-","labels_list","(","list","[","Tensor","]",")",":","Labels","for","all","images",".","-","label_weights_list","(","list","[","Tensor","]",")",":","Label","weights","for","all","images",".","-","kpt_targets_list","(","list","[","Tensor","]",")",":","Keypoint","targets","for","all","images",".","-","kpt_weights_list","(","list","[","Tensor","]",")",":","Keypoint","weights","for","all","images",".","-","area_targets_list","(","list","[","Tensor","]",")",":","area","targets","for","all","images",".","-","num_total_pos","(","int",")",":","Number","of","positive","samples","in","all","images",".","-","num_total_neg","(","int",")",":","Number","of","negative","samples","in","all","images","."]
code: def get_targets(
      self,
      cls_scores_list,
      kpt_preds_list,
      gt_labels_list,
      gt_keypoints_list,
      gt_areas_list,
      img_metas,
  ):
      """Compute regression and classification targets for a batch image.
  
      Outputs from a single decoder layer of a single feature level are used.
  
      Args:
          cls_scores_list (list[Tensor]): Box score logits from a single
              decoder layer for each image with shape [num_query,
              cls_out_channels].
          kpt_preds_list (list[Tensor]): Sigmoid outputs from a single
              decoder layer for each image, with normalized coordinate
              (x_{i}, y_{i}) and shape [num_query, K*2].
          gt_labels_list (list[Tensor]): Ground truth class indices for each
              image with shape (num_gts, ).
          gt_keypoints_list (list[Tensor]): Ground truth keypoints for each
              image with shape (num_gts, K*3).
          gt_areas_list (list[Tensor]): Ground truth mask areas for each
              image with shape (num_gts, ).
          img_metas (list[dict]): List of image meta information.
  
      Returns:
          tuple: a tuple containing the following targets.
  
              - labels_list (list[Tensor]): Labels for all images.
              - label_weights_list (list[Tensor]): Label weights for all
                  images.
              - kpt_targets_list (list[Tensor]): Keypoint targets for all
                  images.
              - kpt_weights_list (list[Tensor]): Keypoint weights for all
                  images.
              - area_targets_list (list[Tensor]): area targets for all
                  images.
              - num_total_pos (int): Number of positive samples in all
                  images.
              - num_total_neg (int): Number of negative samples in all
                  images.
      """
      (
          labels_list,
          label_weights_list,
          kpt_targets_list,
          kpt_weights_list,
          area_targets_list,
          pos_inds_list,
          neg_inds_list,
      ) = multi_apply(
          self._get_target_single,
          cls_scores_list,
          kpt_preds_list,
          gt_labels_list,
          gt_keypoints_list,
          gt_areas_list,
          img_metas,
      )
      num_total_pos = sum((inds.numel() for inds in pos_inds_list))
      num_total_neg = sum((inds.numel() for inds in neg_inds_list))
      return (
          labels_list,
          label_weights_list,
          kpt_targets_list,
          kpt_weights_list,
          area_targets_list,
          num_total_pos,
          num_total_neg,
      )
  
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 10 for calling the PETRHead obj's underlying member method code with example usage: obj.get_targets(cls_scores_list, kpt_preds_list, gt_labels_list, gt_keypoints_list, gt_areas_list, img_metas) and returns: labels_list,  label_weights_list,  kpt_targets_list,  kpt_weights_list,  area_targets_list,  num_total_pos,  num_total_neg