class_docstr: Tests for DeformableDETRTransformer and utilities.
class_docstr_tok: ["Tests","for","DeformableDETRTransformer","and","utilities","."]
docstr: Test get_encoder_reference_points.
docstr_tok: ["Test","get_encoder_reference_points","."]
code: def test_get_encoder_reference_points(self):
      """Test get_encoder_reference_points."""
      shapes = ((10, 10), (2, 2), (30, 30))
      bs, nlevels = 3, len(shapes)
      valid_ratios = jnp.array([1.0, 0.5])[None, None, :] * jnp.ones(
          (bs, nlevels, 2), dtype=jnp.float32
      )
      ref_points = get_encoder_reference_points(shapes, valid_ratios)
      flat_shape = np.array(shapes).prod(1).sum()
  
      self.assertSequenceEqual(
          ref_points.shape, (bs, flat_shape, nlevels, 2)
      )
      delta = 0.5
      self.assertSequenceAlmostEqual(
          ref_points[0, -1, 0], [1.0 - delta / 30.0] * 2
      )
      self.assertSequenceAlmostEqual(
          ref_points[0, 0, 0], [delta / 10.0] * 2
      )
  
imports: from absl.testing import absltest
  from absl.testing import parameterized
  import flax.linen
  import jax
  from jax import random
  import jax.numpy
  import ml_collections
  import numpy
  from scenic.projects.baselines.deformable_detr.deformable_transformer import BBoxCoordPredictor
  from scenic.projects.baselines.deformable_detr.deformable_transformer import DeformableDETRDecoder
  from scenic.projects.baselines.deformable_detr.deformable_transformer import DeformableDETRDecoderLayer
  from scenic.projects.baselines.deformable_detr.deformable_transformer import DeformableDETREncoder
  from scenic.projects.baselines.deformable_detr.deformable_transformer import DeformableDETREncoderLayer
  from scenic.projects.baselines.deformable_detr.deformable_transformer import DeformableDETRTransformer
  from scenic.projects.baselines.deformable_detr.deformable_transformer import get_encoder_reference_points
  from scenic.projects.baselines.deformable_detr.deformable_transformer import get_mask_valid_ratio
  from scenic.projects.baselines.deformable_detr.deformable_transformer import inverse_sigmoid
label_desc: Use image node_id 2 for calling the DeformableDETRTransformerTest obj's underlying member method code with example usage: obj.test_get_encoder_reference_points() without return types