code: def _EncoderBlock(
      d_model,
      d_ff,
      n_heads,
      dropout,
      dropout_shared_axes,
      mode,
      ff_activation,
  ):
      """Returns a list of layers that implements a Transformer encoder block.
  
      The input to the layer is a pair, (activations, mask), where the mask was
      created from the original source tokens to prevent attending to the padding
      part of the input.
  
      Args:
        d_model: int:  depth of embedding
        d_ff: int: depth of feed-forward layer
        n_heads: int: number of attention heads
        dropout: float: dropout rate (how much to drop out)
        dropout_shared_axes: axes on which to share dropout mask
        mode: str: 'train' or 'eval'
        ff_activation: the non-linearity in feed-forward layer
  
      Returns:
        A list of layers that maps (activations, mask) to (activations, mask).
      """
      attention = tl.Attention(
          d_model, n_heads=n_heads, dropout=dropout, mode=mode
      )
  
      feed_forward = _FeedForwardBlock(
          d_model,
          d_ff,
          dropout,
          dropout_shared_axes,
          mode,
          ff_activation,
      )
  
      dropout_ = tl.Dropout(
          rate=dropout, shared_axes=dropout_shared_axes, mode=mode
      )
  
      return [
          ResidualZero(
              tl.LayerNorm(),
              attention,
              dropout_,
          ),
          ResidualZero(
              tl.LayerNorm(),
              feed_forward,
              dropout_,
          ),
      ]
  
file_path: trax/trax/models/research/rezero.py
imports: from trax import layers
  from trax.fastmath import numpy
label_desc: Use image node_id 6 for calling a global function with example usage: _EncoderBlock(d_model, d_ff, n_heads, dropout, dropout_shared_axes, mode, ff_activation) and returns: list