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: Initialize classification branch and keypoint branch of head.
docstr_tok: ["Initialize","classification","branch","and","keypoint","branch","of","head","."]
code: def _init_layers(self):
      """Initialize classification branch and keypoint branch of head."""
  
      fc_cls = nn.Linear(self.embed_dims, self.cls_out_channels)
  
      kpt_branch = []
      kpt_branch.append(nn.Linear(self.embed_dims, 512))
      kpt_branch.append(nn.ReLU())
      for _ in range(self.num_kpt_fcs):
          kpt_branch.append(nn.Linear(512, 512))
          kpt_branch.append(nn.ReLU())
      kpt_branch.append(nn.Linear(512, 2 * self.num_keypoints))
      kpt_branch = nn.Sequential(*kpt_branch)
  
      def _get_clones(module, N):
          return nn.LayerList([copy.deepcopy(module) for i in range(N)])
  
      # last kpt_branch is used to generate proposal from
      # encode feature map when as_two_stage is True.
      num_pred = (
          (self.transformer.decoder.num_layers + 1)
          if self.as_two_stage
          else self.transformer.decoder.num_layers
      )
  
      if self.with_kpt_refine:
          self.cls_branches = _get_clones(fc_cls, num_pred)
          self.kpt_branches = _get_clones(kpt_branch, num_pred)
      else:
          self.cls_branches = nn.LayerList(
              [fc_cls for _ in range(num_pred)]
          )
          self.kpt_branches = nn.LayerList(
              [kpt_branch for _ in range(num_pred)]
          )
  
      self.query_embedding = nn.Embedding(
          self.num_query, self.embed_dims * 2
      )
  
      refine_kpt_branch = []
      for _ in range(self.num_kpt_fcs):
          refine_kpt_branch.append(
              nn.Linear(self.embed_dims, self.embed_dims)
          )
          refine_kpt_branch.append(nn.ReLU())
      refine_kpt_branch.append(nn.Linear(self.embed_dims, 2))
      refine_kpt_branch = nn.Sequential(*refine_kpt_branch)
      if self.with_kpt_refine:
          num_pred = self.transformer.refine_decoder.num_layers
          self.refine_kpt_branches = _get_clones(
              refine_kpt_branch, num_pred
          )
      self.fc_hm = nn.Linear(self.embed_dims, self.num_keypoints)
  
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 2 for calling the PETRHead obj's underlying member method code with example usage: obj._init_layers() and returns: nn