class_docstr: Transformer encoder layer.
  
  Attributes:
    mlp_dim: Dimension of the mlp on top of attention block.
    num_heads: Number of self-attention heads.
    dtype: The dtype of the computation (default: float32).
    dropout_rate: Dropout rate.
    attention_dropout_rate: Dropout for attention heads.
  
  Returns:
    output after transformer encoder block.
class_docstr_tok: ["Transformer","encoder","layer",".","Attributes",":","mlp_dim",":","Dimension","of","the","mlp","on","top","of","attention","block",".","num_heads",":","Number","of","self-attention","heads",".","dtype",":","The","dtype","of","the","computation","(","default",":","float32",")",".","dropout_rate",":","Dropout","rate",".","attention_dropout_rate",":","Dropout","for","attention","heads",".","Returns",":","output","after","transformer","encoder","block","."]
docstr: Applies Encoder1DBlock module.
  
  Args:
    inputs: Input data.
    deterministic: Deterministic or not (to apply dropout).
    droplayer_p: Probability of dropping a layer.
    dataset: Current dataset.
  
  Returns:
    Output after transformer encoder block.
docstr_tok: ["Applies","Encoder1DBlock","module",".","Args",":","inputs",":","Input","data",".","deterministic",":","Deterministic","or","not","(","to","apply","dropout",")",".","droplayer_p",":","Probability","of","dropping","a","layer",".","dataset",":","Current","dataset",".","Returns",":","Output","after","transformer","encoder","block","."]
code: def __call__(
      self,
      inputs: jnp.ndarray,
      deterministic: bool,
      droplayer_p: Optional[float],
      dataset: str,
  ) -> jnp.ndarray:
      """Applies Encoder1DBlock module.
  
      Args:
        inputs: Input data.
        deterministic: Deterministic or not (to apply dropout).
        droplayer_p: Probability of dropping a layer.
        dataset: Current dataset.
  
      Returns:
        Output after transformer encoder block.
      """
      # Attention block.
      assert inputs.ndim == 3
      x = nn.LayerNorm(dtype=self.dtype)(inputs)
      x = nn.MultiHeadDotProductAttention(
          num_heads=self.num_heads,
          dtype=self.dtype,
          kernel_init=nn.initializers.xavier_uniform(),
          broadcast_dropout=False,
          deterministic=deterministic,
          dropout_rate=self.attention_dropout_rate,
      )(x, x)
      x = nn.Dropout(rate=self.dropout_rate)(x, deterministic)
      x = (
          x
          * (
              1.0
              - self.get_droplayer_mask(x, deterministic, droplayer_p)
          )
          + inputs
      )
  
      # MLP block.
      y = nn.LayerNorm(dtype=self.dtype)(x)
      y = MlpBlock(
          dtype=self.dtype,
          mlp_dim=self.mlp_dim,
          dropout_rate=self.dropout_rate,
          kernel_init=nn.initializers.xavier_uniform(),
          bias_init=nn.initializers.normal(stddev=1e-6),
      )(y, train=not deterministic)
  
      return (
          y
          * (
              1.0
              - self.get_droplayer_mask(x, deterministic, droplayer_p)
          )
          + x
      )
  
imports: import functools
  from typing import Any, Callable, Optional, Sequence, Tuple, Union
  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.model_lib.layers import nn_layers
  from scenic.projects.baselines import vit
  from scenic.projects.polyvit import polyvit_base_model
  from scenic.projects.vivit import model
label_desc: Use image node_id 2 for calling the Encoder1DBlock obj's underlying member method code with example usage: obj.__call__(inputs, deterministic, droplayer_p, dataset) and returns: unknown