class_docstr: The Transformer Encoder Layer in Mobile Bert
class_docstr_tok: ["The","Transformer","Encoder","Layer","in","Mobile","Bert"]
docstr: Parameters
  ----------
  data
      - layout = 'NT'
          Shape (batch_size, seq_length, C_in)
      - layout = 'TN'
          Shape (seq_length, batch_size, C_in)
  
  attn_mask
      The attention 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","The","attention","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
          The attention 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._use_bottleneck:
          bn_proj = self.in_bottleneck_proj(data)
          bn_proj = self.in_bottleneck_ln(bn_proj)
          input = bn_proj
          if self._bottleneck_strategy == "qk_sharing":
              # for Mobile Bert
              qk_shared = self.shared_qk(data)
              qk_shared = self.shared_qk_ln(qk_shared)
              query = qk_shared
              key = qk_shared
              value = data
          elif self._bottleneck_strategy == "from_bottleneck":
              # for Mobile Bert Tiny
              query = bn_proj
              key = bn_proj
              value = bn_proj
          elif self._bottleneck_strategy == "from_input":
              query = data
              key = data
              value = data
          else:
              raise NotImplementedError
      else:
          input = data
          query = data
          key = data
          value = data
  
      query = npx.reshape(
          self.attn_query(query), (-2, -2, self._num_heads, -1)
      )
      key = npx.reshape(
          self.attn_key(key), (-2, -2, self._num_heads, -1)
      )
      value = npx.reshape(
          self.attn_value(value), (-2, -2, self._num_heads, -1)
      )
      out, [_, attn_weight] = self.attention_cell(
          query, key, value, attn_mask
      )
      out = self.attention_proj(out)
      if not self._use_bottleneck:
          out = self.dropout_layer(out)
      out = out + input
      out = self.layer_norm(out)
      for ffn_idx in range(self._num_stacked_ffn):
          ffn = self.stacked_ffn[ffn_idx]
          out = ffn(out)
  
      if self._use_bottleneck:
          out = self.out_bottleneck_proj(out)
          out = self.dropout_layer(out)
          out = out + data
          out = self.out_bottleneck_ln(out)
      return out, attn_weight
  
imports: import os
  from typing import Tuple, Optional
  import mxnet
  from mxnet import use_np, np, npx
  from mxnet.gluon import HybridBlock, nn
  from .base import BACKBONE_REGISTRY
  from ..op import select_vectors_by_position
  from ..base import get_model_zoo_home_dir, get_repo_model_zoo_url, get_model_zoo_checksum_dir
  from ..layers import InitializerType, PositionwiseFFN, PositionalEmbedding, get_norm_layer, get_activation
  from ..initializer import TruncNorm
  from ..utils.config import CfgNode
  from ..utils.misc import load_checksum_stats, download
  from ..utils.registry import Registry
  from ..attention_cell import MultiHeadAttentionCell, gen_self_attn_mask
  from ..data.tokenizers import HuggingFaceWordPieceTokenizer
label_desc: Use image node_id 3 for calling the MobileBertEncoderLayer obj's underlying member method code with example usage: obj.forward(data, attn_mask) and returns: out,  attn_weight