class_docstr: Transformer Model for sequence tagging.
class_docstr_tok: ["Transformer","Model","for","sequence","tagging","."]
docstr: Applies Transformer model on the inputs.
  
  Args:
    inputs: input data
    train: if it is training.
  
  Returns:
    output of a transformer encoder.
docstr_tok: ["Applies","Transformer","model","on","the","inputs",".","Args",":","inputs",":","input","data","train",":","if","it","is","training",".","Returns",":","output","of","a","transformer","encoder","."]
code: def __call__(self, *, inputs, train):
      """Applies Transformer model on the inputs.
  
      Args:
        inputs: input data
        train: if it is training.
  
      Returns:
        output of a transformer encoder.
  
      """
      assert inputs.ndim == 2  # (batch, len)
  
      config = self.config
  
      x = inputs.astype("int32")
      x = nn.Embed(
          num_embeddings=config.vocab_size,
          features=config.emb_dim,
          name="embed",
      )(x)
      x = nn.Dropout(rate=config.dropout_rate)(
          x, deterministic=not train
      )
      x = AddPositionEmbs(config)(x)
  
      for _ in range(config.num_layers):
          x = Encoder1DBlock(config)(x, deterministic=not train)
  
      x = nn.LayerNorm(dtype=config.dtype)(x)
      logits = nn.Dense(
          config.output_vocab_size,
          kernel_init=config.kernel_init,
          bias_init=config.bias_init,
      )(x)
      return logits
  
file_path: flax/examples/nlp_seq/models.py
imports: from typing import Callable, Any, Optional
  from flax import linen
  from flax import struct
  import jax.numpy
  import numpy
label_desc: Use image node_id 1 for calling the Transformer obj's underlying member method code with example usage: obj.__call__() and returns: logits