class_docstr: DETR Transformer Encoder.
  
  Attributes:
    num_heads: Number of heads.
    num_layers: Number of layers.
    qkv_dim: Dimension of the query/key/value.
    mlp_dim: Dimension of the mlp on top of attention block.
    normalize_before: If use LayerNorm before attention/mlp blocks.
    norm: normalization layer to be applied on the output.
    dropout_rate: Dropout rate.
    attention_dropout_rate: Dropout rate for attention weights.
    dtype: Data type of the computation (default: float32).
class_docstr_tok: ["DETR","Transformer","Encoder",".","Attributes",":","num_heads",":","Number","of","heads",".","num_layers",":","Number","of","layers",".","qkv_dim",":","Dimension","of","the","query\/key\/value",".","mlp_dim",":","Dimension","of","the","mlp","on","top","of","attention","block",".","normalize_before",":","If","use","LayerNorm","before","attention\/mlp","blocks",".","norm",":","normalization","layer","to","be","applied","on","the","output",".","dropout_rate",":","Dropout","rate",".","attention_dropout_rate",":","Dropout","rate","for","attention","weights",".","dtype",":","Data","type","of","the","computation","(","default",":","float32",")","."]
docstr: Applies Encoder on the inputs.
  
  Args:
    inputs: Input data.
    pos_embedding: Positional Embedding to be added to the queries and keys in
      the self-attention operation.
    padding_mask: Binary mask containing 0 for padding tokens, and 1
      otherwise.
    train: Whether it is training.
  
  Returns:
    Output of the transformer encoder.
code: def __call__(
      self,
      inputs: jnp.ndarray,
      *,
      pos_embedding: Optional[jnp.ndarray] = None,
      padding_mask: Optional[jnp.ndarray] = None,
      train: bool = False,
  ) -> jnp.ndarray:
      """Applies Encoder on the inputs.
  
      Args:
        inputs: Input data.
        pos_embedding: Positional Embedding to be added to the queries and keys in
          the self-attention operation.
        padding_mask: Binary mask containing 0 for padding tokens, and 1
          otherwise.
        train: Whether it is training.
  
      Returns:
        Output of the transformer encoder.
      """
      assert inputs.ndim == 3  # `[batch, height*width, features]`
      x = inputs
  
      # input Encoder
      for lyr in range(self.num_layers):
          x = EncoderBlock(
              qkv_dim=self.qkv_dim,
              mlp_dim=self.mlp_dim,
              num_heads=self.num_heads,
              pre_norm=self.normalize_before,
              dropout_rate=self.dropout_rate,
              attention_dropout_rate=self.attention_dropout_rate,
              name=f"encoderblock_{lyr}",
              dtype=self.dtype,
          )(
              x,
              pos_embedding=pos_embedding,
              padding_mask=padding_mask,
              train=train,
          )
  
      if self.norm is not None:
          x = self.norm(x)
      return x
  
imports: import functools
  from typing import Any, Callable, Dict, Tuple, Optional
  import flax.linen
  import jax
  from jax.nn import initializers
  import jax.numpy
  import ml_collections
  import numpy
  from scenic.model_lib.layers import attention_layers
  from scenic.projects.baselines import resnet
  from scenic.projects.baselines.detr import detr_base_model
label_desc: Use image node_id 1 for calling the Encoder obj's underlying member method code with example usage: obj.__call__(inputs) and returns: x