class_docstr: Transformer Encoder.
  
  Attributes:
    num_layers: Number of layers.
    mlp_dim: Dimension of the mlp on top of attention block.
    inputs_positions: Input subsequence positions for packed examples.
    dropout_rate: Dropout rate.
    stochastic_depth: probability of dropping a layer linearly grows
      from 0 to the provided value. Our implementation of stochastic depth
      follows timm library, which does per-example layer dropping and uses
      independent dropping patterns for each skip-connection.
    dtype: Dtype of activations.
docstr: Applies Transformer model on the inputs.
docstr_tok: ["Applies","Transformer","model","on","the","inputs","."]
code: def __call__(
      self,
      inputs: jnp.ndarray,
      *,
      train: bool = False,
      use_aux_dropout: bool = False,
  ):
      """Applies Transformer model on the inputs."""
  
      assert inputs.ndim == 3  # Shape is `[batch, len, emb]`.
      dtype = jax.dtypes.canonicalize_dtype(self.dtype)
  
      x = AddPositionEmbs(
          posemb_init=nn.initializers.normal(stddev=0.02),  # from BERT.
          name="posembed_input",
      )(inputs)
      x = SplitDropout(
          rate=self.dropout_rate, aux_rate=self.aux_dropout_rate
      )(x, deterministic=not train, use_aux_dropout=use_aux_dropout)
  
      # Input Encoder.
      for lyr in range(self.num_layers):
          clean_sd_coef = self.get_sd_coef(self.sd_direction, lyr)
          aux_sd_coef = self.get_sd_coef(self.aux_sd_direction, lyr)
  
          #      print('sd', self.sd_direction, lyr, sd_coef, flush=True)
          x = Encoder1DBlock(
              mlp_dim=self.mlp_dim,
              num_heads=self.num_heads,
              dropout_rate=self.dropout_rate,
              aux_dropout_rate=self.aux_dropout_rate,
              attention_dropout_rate=self.attention_dropout_rate,
              stochastic_depth=clean_sd_coef * self.stochastic_depth,
              aux_stochastic_depth=aux_sd_coef
              * self.aux_stochastic_depth,
              name=f"encoderblock_{lyr}",
              dtype=dtype,
          )(x, deterministic=not train, use_aux_dropout=use_aux_dropout)
  
      encoded = nn.LayerNorm(name="encoder_norm")(x)
      return encoded
  
imports: from typing import Any, Callable, Optional, Sequence
  from absl import logging
  import flax
  import flax.linen
  import jax
  import jax.numpy
  import ml_collections
  import numpy
  from scenic.model_lib.base_models.multilabel_classification_model import MultiLabelClassificationModel
  from scenic.model_lib.layers import attention_layers
  from scenic.model_lib.layers import nn_layers
  import scipy
label_desc: Use image node_id 2 for calling the Encoder obj's underlying member method code with example usage: obj.__call__(inputs) and returns: encoded