docstr: Generate the representation given the inputs.
  
  This is used in training or fine-tuning a mobile bert model.
  
  Parameters
  ----------
  inputs
      - layout = 'NT'
          Shape (batch_size, seq_length)
      - layout = 'TN'
          Shape (seq_length, batch_size)
  
  token_types
      If the inputs contain two sequences, we will set different token types for the first
      sentence and the second sentence.
  
      - layout = 'NT'
          Shape (batch_size, seq_length)
      - layout = 'TN'
          Shape (seq_length, batch_size)
  
  valid_length
      The valid length of each sequence
      Shape (batch_size,)
  
  Returns
  -------
  contextual_embedding :
      Shape (batch_size, seq_length, units).
  pooled_output :
      This is optional. Shape (batch_size, units)
docstr_tok: ["Generate","the","representation","given","the","inputs",".","This","is","used","in","training","or","fine-tuning","a","mobile","bert","model",".","Parameters","--","--","--","--","--","inputs","-","layout","=","'NT'","Shape","(","batch_size",",","seq_length",")","-","layout","=","'TN'","Shape","(","seq_length",",","batch_size",")","token_types","If","the","inputs","contain","two","sequences",",","we","will","set","different","token","types","for","the","first","sentence","and","the","second","sentence",".","-","layout","=","'NT'","Shape","(","batch_size",",","seq_length",")","-","layout","=","'TN'","Shape","(","seq_length",",","batch_size",")","valid_length","The","valid","length","of","each","sequence","Shape","(","batch_size",",",")","Returns","--","--","--","-","contextual_embedding",":","Shape","(","batch_size",",","seq_length",",","units",")",".","pooled_output",":","This","is","optional",".","Shape","(","batch_size",",","units",")"]
code: def forward(self, inputs, token_types, valid_length):
      # pylint: disable=arguments-differ
      """Generate the representation given the inputs.
  
      This is used in training or fine-tuning a mobile bert model.
  
      Parameters
      ----------
      inputs
          - layout = 'NT'
              Shape (batch_size, seq_length)
          - layout = 'TN'
              Shape (seq_length, batch_size)
  
      token_types
          If the inputs contain two sequences, we will set different token types for the first
          sentence and the second sentence.
  
          - layout = 'NT'
              Shape (batch_size, seq_length)
          - layout = 'TN'
              Shape (seq_length, batch_size)
  
      valid_length
          The valid length of each sequence
          Shape (batch_size,)
  
      Returns
      -------
      contextual_embedding :
          Shape (batch_size, seq_length, units).
      pooled_output :
          This is optional. Shape (batch_size, units)
      """
      embedding = self.get_initial_embedding(inputs, token_types)
  
      if self._compute_layout != self._layout:
          contextual_embeddings, additional_outputs = self.encoder(
              np.swapaxes(embedding, 0, 1), valid_length
          )
          contextual_embeddings = np.swapaxes(
              contextual_embeddings, 0, 1
          )
      else:
          contextual_embeddings, additional_outputs = self.encoder(
              embedding, valid_length
          )
      if self.use_pooler:
          pooled_out = self.apply_pooling(contextual_embeddings)
          return contextual_embeddings, pooled_out
      else:
          return contextual_embeddings
  
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 4 for calling the MobileBertModel obj's underlying member method code with example usage: obj.forward(inputs, token_types, valid_length) and returns: contextual_embeddings,  pooled_out, contextual_embeddings