class_docstr: Implements the PETR transformer.
  
  Args:
      as_two_stage (bool): Generate query from encoder features.
          Default: False.
      num_feature_levels (int): Number of feature maps from FPN:
          Default: 4.
      two_stage_num_proposals (int): Number of proposals when set
          `as_two_stage` as True. Default: 300.
class_docstr_tok: ["Implements","the","PETR","transformer",".","Args",":","as_two_stage","(","bool",")",":","Generate","query","from","encoder","features",".","Default",":","False",".","num_feature_levels","(","int",")",":","Number","of","feature","maps","from","FPN",":","Default",":","4.","two_stage_num_proposals","(","int",")",":","Number","of","proposals","when","set","`","as_two_stage","`","as","True",".","Default",":","300","."]
code: def __init__(
      self,
      encoder="",
      decoder="",
      hm_encoder="",
      refine_decoder="",
      as_two_stage=True,
      num_feature_levels=4,
      two_stage_num_proposals=300,
      num_keypoints=17,
      **kwargs,
  ):
      super(PETRTransformer, self).__init__(**kwargs)
      self.as_two_stage = as_two_stage
      self.num_feature_levels = num_feature_levels
      self.two_stage_num_proposals = two_stage_num_proposals
      self.num_keypoints = num_keypoints
      self.encoder = encoder
      self.decoder = decoder
      self.embed_dims = self.encoder.embed_dims
      self.hm_encoder = hm_encoder
      self.refine_decoder = refine_decoder
      self.init_layers()
      self.init_weights()
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import math
  import numpy
  import paddle
  import paddle.nn
  import paddle.nn.functional
  from paddle import ParamAttr
  from ppdet.core.workspace import register
  from ..layers import MultiHeadAttention, _convert_attention_mask
  from .utils import _get_clones
  from ..initializer import linear_init_, normal_, constant_, xavier_uniform_
label_desc: Use image node_id 1 to create a new PETRTransformer object from inherited base classes: nn with example: obj = PETRTransformer(encoder, decoder, hm_encoder, refine_decoder, as_two_stage, num_feature_levels, two_stage_num_proposals, num_keypoints)