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","."]
docstr: Initialize the transformer weights.
docstr_tok: ["Initialize","the","transformer","weights","."]
code: def init_weights(self):
      """Initialize the transformer weights."""
      for p in self.parameters():
          if p.rank() > 1:
              xavier_uniform_(p)
              if hasattr(p, "bias") and p.bias is not None:
                  constant_(p.bais)
      for m in self.sublayers():
          if isinstance(m, MSDeformableAttention):
              m._reset_parameters()
      for m in self.sublayers():
          if isinstance(m, MultiScaleDeformablePoseAttention):
              m.init_weights()
      if not self.as_two_stage:
          xavier_uniform_(self.reference_points.weight)
          constant_(self.reference_points.bias)
      normal_(self.level_embeds)
      normal_(self.refine_query_embedding.weight)
  
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 3 for calling the PETRTransformer obj's underlying member method code with example usage: obj.init_weights() without return types