class_docstr: Transformer Model Encoder for sequence to sequence translation.
  
  Attributes:
    config: TransformerConfig dataclass containing hyperparameters.
    shared_embedding: a shared embedding layer to use.
class_docstr_tok: ["Transformer","Model","Encoder","for","sequence","to","sequence","translation",".","Attributes",":","config",":","TransformerConfig","dataclass","containing","hyperparameters",".","shared_embedding",":","a","shared","embedding","layer","to","use","."]
docstr: Applies Transformer model on the inputs.
  
  Args:
    inputs: input data
    inputs_positions: input subsequence positions for packed examples.
    encoder_mask: decoder self-attention mask.
  
  Returns:
    output of a transformer encoder.
docstr_tok: ["Applies","Transformer","model","on","the","inputs",".","Args",":","inputs",":","input","data","inputs_positions",":","input","subsequence","positions","for","packed","examples",".","encoder_mask",":","decoder","self-attention","mask",".","Returns",":","output","of","a","transformer","encoder","."]
code: def __call__(self, inputs, inputs_positions=None, encoder_mask=None):
      """Applies Transformer model on the inputs.
  
      Args:
        inputs: input data
        inputs_positions: input subsequence positions for packed examples.
        encoder_mask: decoder self-attention mask.
  
      Returns:
        output of a transformer encoder.
      """
      config = self.config
      assert inputs.ndim == 2  # (batch, len)
  
      # Input Embedding
      if self.shared_embedding is None:
          input_embed = nn.Embed(
              num_embeddings=config.vocab_size,
              features=config.emb_dim,
              embedding_init=nn.initializers.normal(stddev=1.0),
          )
      else:
          input_embed = self.shared_embedding
      x = inputs.astype("int32")
      x = input_embed(x)
      x = AddPositionEmbs(
          config=config, decode=False, name="posembed_input"
      )(x, inputs_positions=inputs_positions)
      x = nn.Dropout(rate=config.dropout_rate)(
          x, deterministic=config.deterministic
      )
  
      x = x.astype(config.dtype)
  
      # Input Encoder
      for lyr in range(config.num_layers):
          x = Encoder1DBlock(config=config, name=f"encoderblock_{lyr}")(
              x, encoder_mask
          )
  
      encoded = nn.LayerNorm(dtype=config.dtype, name="encoder_norm")(x)
  
      return encoded
  
imports: from __future__ import annotations
  from typing import Callable, Any, Optional
  from flax import linen
  from flax import struct
  from jax import lax
  import jax.numpy
  import numpy
label_desc: Use image node_id 1 for calling the Encoder obj's underlying member method code with example usage: obj.__call__(inputs, inputs_positions, encoder_mask) and returns: encoded