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 __init__(
      self,
      num_classes,
      in_channels,
      num_query=100,
      num_kpt_fcs=2,
      num_keypoints=17,
      transformer=None,
      sync_cls_avg_factor=True,
      positional_encoding="SinePositionalEncoding",
      loss_cls="FocalLoss",
      loss_kpt="L1Loss",
      loss_oks="OKSLoss",
      loss_hm="CenterFocalLoss",
      with_kpt_refine=True,
      assigner="PoseHungarianAssigner",
      sampler="PseudoSampler",
      loss_kpt_rpn="L1Loss",
      loss_kpt_refine="L1Loss",
      loss_oks_refine="opera.OKSLoss",
      test_cfg=dict(max_per_img=100),
      init_cfg=None,
      **kwargs,
  ):
      # NOTE here use `AnchorFreeHead` instead of `TransformerHead`,
      # since it brings inconvenience when the initialization of
      # `AnchorFreeHead` is called.
      super().__init__()
      self.bg_cls_weight = 0
      self.sync_cls_avg_factor = sync_cls_avg_factor
      self.assigner = assigner
      self.sampler = sampler
      self.num_query = num_query
      self.num_classes = num_classes
      self.in_channels = in_channels
      self.num_kpt_fcs = num_kpt_fcs
      self.test_cfg = test_cfg
      self.fp16_enabled = False
      self.as_two_stage = transformer.as_two_stage
      self.with_kpt_refine = with_kpt_refine
      self.num_keypoints = num_keypoints
      self.loss_cls = loss_cls
      self.loss_kpt = loss_kpt
      self.loss_kpt_rpn = loss_kpt_rpn
      self.loss_kpt_refine = loss_kpt_refine
      self.loss_oks = loss_oks
      self.loss_oks_refine = loss_oks_refine
      self.loss_hm = loss_hm
      if self.loss_cls.use_sigmoid:
          self.cls_out_channels = num_classes
      else:
          self.cls_out_channels = num_classes + 1
      self.positional_encoding = positional_encoding
      self.transformer = transformer
      self.embed_dims = self.transformer.embed_dims
      # assert 'num_feats' in positional_encoding
      num_feats = positional_encoding.num_pos_feats
      assert num_feats * 2 == self.embed_dims, (
          "embed_dims should"
          f" be exactly 2 times of num_feats. Found {self.embed_dims}"
          f" and {num_feats}."
      )
      self._init_layers()
      self.init_weights()
  
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 1 to create a new PETRHead object from inherited base classes: nn with example: obj = PETRHead(num_classes, in_channels, num_query, num_kpt_fcs, num_keypoints, transformer, sync_cls_avg_factor, positional_encoding, loss_cls, loss_kpt, loss_oks, loss_hm, with_kpt_refine, assigner, sampler, loss_kpt_rpn, loss_kpt_refine, loss_oks_refine, test_cfg, init_cfg)