class_docstr: Transformer Encoder Layer
class_docstr_tok: ["Transformer","Encoder","Layer"]
docstr: Parameters
  ----------
  data
      - layout = 'NT'
          Shape (batch_size, seq_length, C_in)
      - layout = 'TN'
          Shape (seq_length, batch_size, C_in)
  
  attn_mask
      Shape (batch_size, seq_length, seq_length)
  
  Returns
  -------
  out
      - layout = 'NT'
          Shape (batch_size, seq_length, C_out)
      - layout = 'TN'
          Shape (seq_length, batch_size, C_out)
  
  attn_weight
      Shape (batch_size, seq_length, seq_length)
docstr_tok: ["Parameters","--","--","--","--","--","data","-","layout","=","'NT'","Shape","(","batch_size",",","seq_length",",","C_in",")","-","layout","=","'TN'","Shape","(","seq_length",",","batch_size",",","C_in",")","attn_mask","Shape","(","batch_size",",","seq_length",",","seq_length",")","Returns","--","--","--","-","out","-","layout","=","'NT'","Shape","(","batch_size",",","seq_length",",","C_out",")","-","layout","=","'TN'","Shape","(","seq_length",",","batch_size",",","C_out",")","attn_weight","Shape","(","batch_size",",","seq_length",",","seq_length",")"]
code: def forward(self, data, attn_mask):
      """
  
      Parameters
      ----------
      data
          - layout = 'NT'
              Shape (batch_size, seq_length, C_in)
          - layout = 'TN'
              Shape (seq_length, batch_size, C_in)
  
      attn_mask
          Shape (batch_size, seq_length, seq_length)
  
      Returns
      -------
      out
          - layout = 'NT'
              Shape (batch_size, seq_length, C_out)
          - layout = 'TN'
              Shape (seq_length, batch_size, C_out)
  
      attn_weight
          Shape (batch_size, seq_length, seq_length)
      """
      if self._pre_norm:
          data = self.layer_norm(data)
      query, key, value = np.split(self.attn_qkv(data), 3, axis=-1)
      query = npx.reshape(query, (-2, -2, self._num_heads, -1))
      key = npx.reshape(key, (-2, -2, self._num_heads, -1))
      value = npx.reshape(value, (-2, -2, self._num_heads, -1))
      out, [_, attn_weight] = self.attention_cell(
          query, key, value, attn_mask
      )
      out = self.attention_proj(out)
      out = self.dropout_layer(out)
      out = out + data
      if not self._pre_norm:
          out = self.layer_norm(out)
      out = self.ffn(out)
      return out, attn_weight
  
imports: import numpy
  import mxnet
  from mxnet import np, npx
  from mxnet import use_np
  from mxnet.gluon import nn, HybridBlock
  from typing import Optional, Tuple, List
  from ..utils.registry import Registry
  from ..attention_cell import MultiHeadAttentionCell, gen_self_attn_mask, gen_mem_attn_mask
  from ..layers import PositionalEmbedding, PositionwiseFFN, InitializerType
  from ..utils.config import CfgNode
  from ..sequence_sampler import BaseStepDecoder
label_desc: Use image node_id 3 for calling the TransformerEncoderLayer obj's underlying member method code with example usage: obj.forward(data, attn_mask) and returns: out,  attn_weight