class_docstr: XViT 1D Encoder.
  
  Attributes:
    mlp_dim: Dimension of the MLP on top of attention block.
    num_layers: Number of layers.
    attention_configs: Configurations passed to the self-attention.
    attention_fn: Self-attention function used in the model.
    dropout_rate:  Dropout rate.
    attention_dropout_rate: Dropout for attention heads.
    num_kernel_features: Number of kernel features used.
    redraw: Whether to redraw (applicabl only if random features are used).
class_docstr_tok: ["XViT","1D","Encoder",".","Attributes",":","mlp_dim",":","Dimension","of","the","MLP","on","top","of","attention","block",".","num_layers",":","Number","of","layers",".","attention_configs",":","Configurations","passed","to","the","self-attention",".","attention_fn",":","Self-attention","function","used","in","the","model",".","dropout_rate",":","Dropout","rate",".","attention_dropout_rate",":","Dropout","for","attention","heads",".","num_kernel_features",":","Number","of","kernel","features","used",".","redraw",":","Whether","to","redraw","(","applicabl","only","if","random","features","are","used",")","."]
docstr: Applies Transformer model on the inputs.
  
  Args:
    inputs: Input data.
    train: If it is training.
  
  Returns:
docstr_tok: ["Applies","Transformer","model","on","the","inputs",".","Args",":","inputs",":","Input","data",".","train",":","If","it","is","training",".","Returns",":"]
code: def __call__(
      self,
      inputs: jnp.ndarray,
      train: bool,
  ) -> jnp.ndarray:
      """Applies Transformer model on the inputs.
  
      Args:
        inputs: Input data.
        train: If it is training.
  
      Returns:
      """
      assert inputs.ndim == 3  # Shape is `[batch, len, emb]`.
      x = attention_layers.Add1DPositionEmbedding(
          posemb_init=nn.initializers.normal(stddev=0.02),  # From BERT.
          name="posembed_input",
      )(inputs)
      x = nn.Dropout(rate=self.dropout_rate)(x, deterministic=not train)
  
      # Input encoder.
      for lyr in range(self.num_layers):
          x = model_utils.Encoder1DBlock(  # pytype: disable=wrong-arg-types  # jax-ndarray
              mlp_dim=self.mlp_dim,
              attention_fn=self.attention_fn,
              attention_configs=self.attention_configs,
              dropout_rate=self.dropout_rate,
              attention_dropout_rate=self.attention_dropout_rate,
              num_kernel_features=self.num_kernel_features,
              redraw=self.redraw,
              name=f"encoder_block_{lyr}",
          )(
              x, inputs_kv=None, deterministic=not train
          )
  
      return nn.LayerNorm(name="encoder_norm")(x)
  
imports: from typing import Any, Optional
  import flax.linen
  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
  from scenic.model_lib.layers import nn_ops
  from scenic.projects.baselines import vit
  from scenic.projects.fast_vit import model_utils
label_desc: Use image node_id 1 for calling the Encoder1D obj's underlying member method code with example usage: obj.__call__(inputs, train) and returns: nn