class_docstr: DeformableDETR Transformer.
  
  Attributes:
    embed_dim: Size of the hidden embedding dimension.
    enc_embed_dim: Size of the hidden embedding dimension for encoder.
    num_heads: Number of heads.
    num_queries: Number of object queries.
    num_enc_layers: Number of encoder layers.
    num_dec_layers: Number of decoder layers.
    num_enc_points: Number of encoder points in deformable attention.
    num_dec_points: Number of decoder points in deformable attention.
    ffn_dim: Size of feed-forward network embedding.
    dropout: Dropout rate.
    compiler_config: Compiler configuration.
    dtype: Data type of the computation (default: float32).
code: def __call__(
      self,
      inputs: Sequence[jnp.ndarray],
      pad_masks: Sequence[jnp.ndarray],
      pos_embeds: Sequence[jnp.ndarray],
      train: bool,
  ) -> Tuple[jnp.ndarray, jnp.ndarray, jnp.ndarray]:
      # Prepare inputs for encoder.
      spatial_shapes = tuple([inp.shape[1:3] for inp in inputs])
      num_levels = len(spatial_shapes)
  
      level_embeds = jnp.asarray(
          self.param(
              "level_embed",
              nn.initializers.normal(stddev=1.0),
              (num_levels, self.enc_embed_dim),
          )
      )
      (x, valid_ratios, pos_embeds, pad_masks) = prepare_encoder_input(
          inputs=inputs,
          masks=pad_masks,
          pos_embeds=pos_embeds,
          level_embeds=level_embeds,
      )
  
      enc_ref_points = get_encoder_reference_points(
          tuple(spatial_shapes), valid_ratios
      )
  
      # Encoder.
      encoder = DeformableDETREncoder(
          spatial_shapes=spatial_shapes,
          embed_dim=self.enc_embed_dim,
          num_heads=self.num_heads,
          num_layers=self.num_enc_layers,
          num_levels=num_levels,
          ffn_dim=self.ffn_dim,
          num_reference_points=self.num_enc_points,
          dropout=self.dropout,
          compiler_config=self.compiler_config,
          dtype=self.dtype,
          name="encoder",
      )
  
      x = encoder(
          src=x,
          pos_embed=pos_embeds,
          ref_points=enc_ref_points,
          pad_mask=pad_masks,
          train=train,
      )
  
      # Project encoder output to decoder embedding. Note that this layer does
      # not exist in the reference implementation. However, this greatly reduces
      # the amount of memory required while training and seems to have no
      # noticeable effect in COCO mAP.
      if self.enc_embed_dim != self.embed_dim:
          x = nn.Conv(
              features=self.embed_dim,
              kernel_size=(1,),
              name="enc_to_dec_proj_conv",
          )(x)
          x = nn.GroupNorm(
              num_groups=32, name="enc_to_dec_proj_groupnorm"
          )(x)
  
      query_embed = jnp.asarray(
          self.param(
              "query_embed",
              nn.initializers.normal(stddev=1.0),
              (self.num_queries, self.embed_dim * 2),
          )
      )
  
      # Prepare decoder input.
      bs = x.shape[0]
      query_embed = query_embed[None, ...].repeat(bs, 0)
      query_embed, query = jnp.split(
          query_embed, indices_or_sections=2, axis=-1
      )
      dec_init_ref_points = nn.Dense(2, name="ref_embed")(query_embed)
      dec_init_ref_points = nn.sigmoid(dec_init_ref_points)
  
      x, ref_points = DeformableDETRDecoder(
          spatial_shapes=spatial_shapes,
          embed_dim=self.embed_dim,
          num_heads=self.num_heads,
          num_layers=self.num_dec_layers,
          num_levels=num_levels,
          ffn_dim=self.ffn_dim,
          num_reference_points=self.num_dec_points,
          bbox_embeds=self.bbox_embeds,
          dropout=self.dropout,
          compiler_config=self.compiler_config,
          dtype=self.dtype,
          name="decoder",
      )(
          value=x,
          query=query,
          query_pos=query_embed,
          ref_points=dec_init_ref_points,
          pad_mask=pad_masks,
          valid_ratios=valid_ratios,
          train=train,
      )
  
      return x, ref_points, dec_init_ref_points
  
imports: import functools
  from typing import Sequence, Tuple
  import flax.linen
  import jax
  import jax.numpy
  import ml_collections
  import numpy
  from scenic.projects.baselines.deformable_detr.attention import MultiScaleDeformableAttention
  from scenic.projects.baselines.detr.model import MultiHeadDotProductAttention
label_desc: Use image node_id 1 for calling the DeformableDETRTransformer obj's underlying member method code with example usage: obj.__call__(inputs, pad_masks, pos_embeds, train) and returns: x,  ref_points,  dec_init_ref_points