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: Transform network outputs for a batch into bbox predictions.
  
  Args:
      all_cls_scores (Tensor): Classification score of all
          decoder layers, has shape
          [nb_dec, bs, num_query, cls_out_channels].
      all_kpt_preds (Tensor): Sigmoid regression
          outputs of all decode layers. Each is a 4D-tensor with
          normalized coordinate format (x_{i}, y_{i}) and shape
          [nb_dec, bs, num_query, K*2].
      enc_cls_scores (Tensor): Classification scores of points on
          encode feature map, has shape (N, h*w, num_classes).
          Only be passed when as_two_stage is True, otherwise is None.
      enc_kpt_preds (Tensor): Regression results of each points
          on the encode feature map, has shape (N, h*w, K*2). Only be
          passed when as_two_stage is True, otherwise is None.
      img_metas (list[dict]): Meta information of each image.
      rescale (bool, optional): If True, return boxes in original
          image space. Defalut False.
  
  Returns:
      list[list[Tensor, Tensor]]: Each item in result_list is 3-tuple.
          The first item is an (n, 5) tensor, where the first 4 columns
          are bounding box positions (tl_x, tl_y, br_x, br_y) and the
          5-th column is a score between 0 and 1. The second item is a
          (n,) tensor where each item is the predicted class label of
          the corresponding box. The third item is an (n, K, 3) tensor
          with [p^{1}_x, p^{1}_y, p^{1}_v, ..., p^{K}_x, p^{K}_y,
          p^{K}_v] format.
docstr_tok: ["Transform","network","outputs","for","a","batch","into","bbox","predictions",".","Args",":","all_cls_scores","(","Tensor",")",":","Classification","score","of","all","decoder","layers",",","has","shape","[","nb_dec",",","bs",",","num_query",",","cls_out_channels","]",".","all_kpt_preds","(","Tensor",")",":","Sigmoid","regression","outputs","of","all","decode","layers",".","Each","is","a","4D-tensor","with","normalized","coordinate","format","(","x_","{","i","}",",","y_","{","i","}",")","and","shape","[","nb_dec",",","bs",",","num_query",",","K","*","2","]",".","enc_cls_scores","(","Tensor",")",":","Classification","scores","of","points","on","encode","feature","map",",","has","shape","(","N",",","h","*","w",",","num_classes",")",".","Only","be","passed","when","as_two_stage","is","True",",","otherwise","is","None",".","enc_kpt_preds","(","Tensor",")",":","Regression","results","of","each","points","on","the","encode","feature","map",",","has","shape","(","N",",","h","*","w",",","K","*","2",")",".","Only","be","passed","when","as_two_stage","is","True",",","otherwise","is","None",".","img_metas","(","list","[","dict","]",")",":","Meta","information","of","each","image",".","rescale","(","bool",",","optional",")",":","If","True",",","return","boxes","in","original","image","space",".","Defalut","False",".","Returns",":","list","[","list","[","Tensor",",","Tensor","]","]",":","Each","item","in","result_list","is","3-tuple",".","The","first","item","is","an","(","n",",","5",")","tensor",",","where","the","first","4","columns","are","bounding","box","positions","(","tl_x",",","tl_y",",","br_x",",","br_y",")","and","the","5-th","column","is","a","score","between","0","and","1",".","The","second","item","is","a","(","n",",",")","tensor","where","each","item","is","the","predicted","class","label","of","the","corresponding","box",".","The","third","item","is","an","(","n",",","K",",","3",")","tensor","with","[","p^","{","1","}","_x",",","p^","{","1","}","_y",",","p^","{","1","}","_v",",","...",",","p^","{","K","}","_x",",","p^","{","K","}","_y",",","p^","{","K","}","_v","]","format","."]
code: def get_bboxes(
      self,
      all_cls_scores,
      all_kpt_preds,
      enc_cls_scores,
      enc_kpt_preds,
      hm_proto,
      memory,
      mlvl_masks,
      img_metas,
      rescale=False,
  ):
      """Transform network outputs for a batch into bbox predictions.
  
      Args:
          all_cls_scores (Tensor): Classification score of all
              decoder layers, has shape
              [nb_dec, bs, num_query, cls_out_channels].
          all_kpt_preds (Tensor): Sigmoid regression
              outputs of all decode layers. Each is a 4D-tensor with
              normalized coordinate format (x_{i}, y_{i}) and shape
              [nb_dec, bs, num_query, K*2].
          enc_cls_scores (Tensor): Classification scores of points on
              encode feature map, has shape (N, h*w, num_classes).
              Only be passed when as_two_stage is True, otherwise is None.
          enc_kpt_preds (Tensor): Regression results of each points
              on the encode feature map, has shape (N, h*w, K*2). Only be
              passed when as_two_stage is True, otherwise is None.
          img_metas (list[dict]): Meta information of each image.
          rescale (bool, optional): If True, return boxes in original
              image space. Defalut False.
  
      Returns:
          list[list[Tensor, Tensor]]: Each item in result_list is 3-tuple.
              The first item is an (n, 5) tensor, where the first 4 columns
              are bounding box positions (tl_x, tl_y, br_x, br_y) and the
              5-th column is a score between 0 and 1. The second item is a
              (n,) tensor where each item is the predicted class label of
              the corresponding box. The third item is an (n, K, 3) tensor
              with [p^{1}_x, p^{1}_y, p^{1}_v, ..., p^{K}_x, p^{K}_y,
              p^{K}_v] format.
      """
      cls_scores = all_cls_scores[-1]
      kpt_preds = all_kpt_preds[-1]
  
      result_list = []
      for img_id in range(len(img_metas)):
          cls_score = cls_scores[img_id]
          kpt_pred = kpt_preds[img_id]
          img_shape = img_metas[img_id]["img_shape"]
          scale_factor = img_metas[img_id]["scale_factor"]
          # TODO: only support single image test
          # memory_i = memory[:, img_id, :]
          # mlvl_mask = mlvl_masks[img_id]
          proposals = self._get_bboxes_single(
              cls_score,
              kpt_pred,
              img_shape,
              scale_factor,
              memory,
              mlvl_masks,
              rescale,
          )
          result_list.append(proposals)
      return result_list
  
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 13 for calling the PETRHead obj's underlying member method code with example usage: obj.get_bboxes(all_cls_scores, all_kpt_preds, enc_cls_scores, enc_kpt_preds, hm_proto, memory, mlvl_masks, img_metas, rescale) and returns: result_list