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: Get the reference points used in decoder.
  
  Args:
      spatial_shapes (Tensor): The shape of all feature maps,
          has shape (num_level, 2).
      valid_ratios (Tensor): The radios of valid points on the
          feature map, has shape (bs, num_levels, 2).
  
  Returns:
      Tensor: reference points used in decoder, has                 shape (bs, num_keys, num_levels, 2).
docstr_tok: ["Get","the","reference","points","used","in","decoder",".","Args",":","spatial_shapes","(","Tensor",")",":","The","shape","of","all","feature","maps",",","has","shape","(","num_level",",","2",")",".","valid_ratios","(","Tensor",")",":","The","radios","of","valid","points","on","the","feature","map",",","has","shape","(","bs",",","num_levels",",","2",")",".","Returns",":","Tensor",":","reference","points","used","in","decoder",",","has","shape","(","bs",",","num_keys",",","num_levels",",","2",")","."]
code: def get_reference_points(spatial_shapes, valid_ratios):
      """Get the reference points used in decoder.
  
          Args:
              spatial_shapes (Tensor): The shape of all feature maps,
                  has shape (num_level, 2).
              valid_ratios (Tensor): The radios of valid points on the
                  feature map, has shape (bs, num_levels, 2).
  
          Returns:
              Tensor: reference points used in decoder, has \
                  shape (bs, num_keys, num_levels, 2).
          """
      reference_points_list = []
      for lvl, (H, W) in enumerate(spatial_shapes):
          ref_y, ref_x = paddle.meshgrid(
              paddle.linspace(0.5, H - 0.5, H, dtype="float32"),
              paddle.linspace(0.5, W - 0.5, W, dtype="float32"),
          )
          ref_y = ref_y.reshape((-1,))[None] / (
              valid_ratios[:, None, lvl, 1] * H
          )
          ref_x = ref_x.reshape((-1,))[None] / (
              valid_ratios[:, None, lvl, 0] * W
          )
          ref = paddle.stack((ref_x, ref_y), -1)
          reference_points_list.append(ref)
      reference_points = paddle.concat(reference_points_list, 1)
      reference_points = (
          reference_points[:, :, None] * valid_ratios[:, None]
      )
      return reference_points
  
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 5 for calling the PETRTransformer obj's underlying member method code with example usage: obj.get_reference_points(spatial_shapes, valid_ratios) and returns: reference_points