class_docstr: Transformer Model for sequence to sequence translation.
  
  Attributes:
    config: TransformerConfig dataclass containing hyperparameters.
class_docstr_tok: ["Transformer","Model","for","sequence","to","sequence","translation",".","Attributes",":","config",":","TransformerConfig","dataclass","containing","hyperparameters","."]
docstr: Applies Transformer encoder-branch on the inputs.
  
  Args:
    inputs: input data.
    inputs_positions: input subsequence positions for packed examples.
    inputs_segmentation: input segmentation info for packed examples.
  
  Returns:
    encoded feature array from the transformer encoder.
docstr_tok: ["Applies","Transformer","encoder-branch","on","the","inputs",".","Args",":","inputs",":","input","data",".","inputs_positions",":","input","subsequence","positions","for","packed","examples",".","inputs_segmentation",":","input","segmentation","info","for","packed","examples",".","Returns",":","encoded","feature","array","from","the","transformer","encoder","."]
code: def encode(
      self, inputs, inputs_positions=None, inputs_segmentation=None
  ):
      """Applies Transformer encoder-branch on the inputs.
  
      Args:
        inputs: input data.
        inputs_positions: input subsequence positions for packed examples.
        inputs_segmentation: input segmentation info for packed examples.
  
      Returns:
        encoded feature array from the transformer encoder.
      """
      config = self.config
      # Make padding attention mask.
      encoder_mask = nn.make_attention_mask(
          inputs > 0, inputs > 0, dtype=config.dtype
      )
      # Add segmentation block-diagonal attention mask if using segmented data.
      if inputs_segmentation is not None:
          encoder_mask = nn.combine_masks(
              encoder_mask,
              nn.make_attention_mask(
                  inputs_segmentation,
                  inputs_segmentation,
                  jnp.equal,
                  dtype=config.dtype,
              ),
          )
      return self.encoder(
          inputs,
          inputs_positions=inputs_positions,
          encoder_mask=encoder_mask,
      )
  
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 2 for calling the Transformer obj's underlying member method code with example usage: obj.encode(inputs, inputs_positions, inputs_segmentation) and returns: self