class_docstr: Transformer/BERT encoder layer.
  
  Attributes:
    mlp_dim: Dimension of the mlp on top of attention block.
    num_heads: Number of self-attention heads.
    dropout_rate: Dropout rate.
    attention_dropout_rate: Dropout for attention heads.
    pre_norm: Whether to use PreLN, otherwise PostLN. For more detail, see
      https://arxiv.org/pdf/2002.04745.pdf.
    dtype: The dtype of the computation (default: float32).
  
  Returns:
    output after transformer encoder block.
class_docstr_tok: ["Transformer\/BERT","encoder","layer",".","Attributes",":","mlp_dim",":","Dimension","of","the","mlp","on","top","of","attention","block",".","num_heads",":","Number","of","self-attention","heads",".","dropout_rate",":","Dropout","rate",".","attention_dropout_rate",":","Dropout","for","attention","heads",".","pre_norm",":","Whether","to","use","PreLN",",","otherwise","PostLN",".","For","more","detail",",","see","https",":","\/\/arxiv.org\/pdf\/2002.04745.pdf",".","dtype",":","The","dtype","of","the","computation","(","default",":","float32",")",".","Returns",":","output","after","transformer","encoder","block","."]
docstr: Applies Encoder1DBlock module.
  
  Args:
    inputs: Input data.
    input_mask: Input mask, used for text input.
    deterministic: Deterministic or not (to apply dropout).
  
  Returns:
    Output after transformer encoder block.
docstr_tok: ["Applies","Encoder1DBlock","module",".","Args",":","inputs",":","Input","data",".","input_mask",":","Input","mask",",","used","for","text","input",".","deterministic",":","Deterministic","or","not","(","to","apply","dropout",")",".","Returns",":","Output","after","transformer","encoder","block","."]
code: def __call__(
      self,
      inputs: jnp.ndarray,
      input_mask: Optional[jnp.ndarray],
      deterministic: bool,
  ) -> jnp.ndarray:
      """Applies Encoder1DBlock module.
  
      Args:
        inputs: Input data.
        input_mask: Input mask, used for text input.
        deterministic: Deterministic or not (to apply dropout).
  
      Returns:
        Output after transformer encoder block.
      """
      # Attention block.
      assert inputs.ndim == 3
  
      # pre-attention-layer-normalization
      x = (
          nn.LayerNorm(dtype=self.dtype)(inputs)
          if self.pre_norm
          else inputs
      )
      attention_mask = input_mask[:, None, None, :] * jnp.ones(
          [1, 1, x.shape[1], 1]
      )
      x = nn.MultiHeadDotProductAttention(
          num_heads=self.num_heads,
          dtype=self.dtype,
          kernel_init=nn.initializers.xavier_uniform(),
          broadcast_dropout=False,
          dropout_rate=self.attention_dropout_rate,
      )(x, x, mask=attention_mask, deterministic=deterministic)
      x = nn.Dropout(rate=self.dropout_rate)(x, deterministic)
      x = x + inputs
      if not self.pre_norm:  # post-attention-layer-normalization
          # Normalized x is used for residual connection.
          x = nn.LayerNorm(dtype=self.dtype)(x)
  
      # MLP block.
      if self.pre_norm:  # pre-mlp-layer-normalization
          # Do not overwrite x because it will be used for residual connection.
          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 if self.pre_norm else x, train=not deterministic)
      y = y + x
      # post-mlp-layer-normalization
      if not self.pre_norm:
          y = nn.LayerNorm(dtype=self.dtype)(y)
      return y
  
imports: from typing import Any, Callable, Optional, Sequence, Tuple, Union
  import flax.linen
  import jax
  from jax.nn import initializers
  import jax.numpy
  import numpy
  from scenic.model_lib.layers import nn_layers
label_desc: Use image node_id 1 for calling the Encoder1DBlock obj's underlying member method code with example usage: obj.__call__(inputs, input_mask, deterministic) and returns: y