class_docstr: Electra Model
  
  This is almost the same as bert model with embedding_size adjustable (factorized embedding).
class_docstr_tok: ["Electra","Model","This","is","almost","the","same","as","bert","model","with","embedding_size","adjustable","(","factorized","embedding",")","."]
docstr: Generate the representation given the inputs.
  
  This is used in training or fine-tuning a Electra 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
      - layout = 'NT'
          Shape (batch_size, seq_length, units).
      - layout = 'TN'
          Shape (seq_length, batch_size, 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","Electra","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","-","layout","=","'NT'","Shape","(","batch_size",",","seq_length",",","units",")",".","-","layout","=","'TN'","Shape","(","seq_length",",","batch_size",",","units",")",".","pooled_output","This","is","optional",".","Shape","(","batch_size",",","units",")"]
code: def forward(self, inputs, token_types, valid_length=None):
      """Generate the representation given the inputs.
  
      This is used in training or fine-tuning a Electra 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
          - layout = 'NT'
              Shape (batch_size, seq_length, units).
          - layout = 'TN'
              Shape (seq_length, batch_size, units).
  
      pooled_output
          This is optional. Shape (batch_size, units)
      """
      initial_embedding = self.get_initial_embedding(
          inputs, token_types
      )
      # Projecting the embedding into units
      prev_out = initial_embedding
      if self.embed_size != self.units:
          prev_out = self.embed_factorized_proj(prev_out)
      outputs = []
      if self._compute_layout != self._layout:
          # Swap the axes if the compute_layout and layout mismatch
          contextual_embeddings, additional_outputs = self.encoder(
              np.swapaxes(prev_out, 0, 1), valid_length
          )
          contextual_embeddings = np.swapaxes(
              contextual_embeddings, 0, 1
          )
      else:
          contextual_embeddings, additional_outputs = self.encoder(
              prev_out, valid_length
          )
      outputs.append(contextual_embeddings)
      if self.use_pooler:
          # Here we just get the first token ([CLS]) without any pooling strategy,
          # which is slightly different from bert model with the pooled_out
          # the attribute name is keeping the same as bert and albert model with defualt
          # use_pooler=True
          if self._layout == "NT":
              pooled_out = contextual_embeddings[:, 0, :]
          else:
              pooled_out = contextual_embeddings[0, :, :]
          outputs.append(pooled_out)
      return tuple(outputs) if len(outputs) > 1 else outputs[0]
  
imports: import os
  from typing import Tuple, Optional, List
  import mxnet
  from mxnet import use_np, np, npx
  from mxnet.gluon import HybridBlock, nn
  from .base import BACKBONE_REGISTRY
  from .transformer import TransformerEncoderLayer
  from ..op import gumbel_softmax, select_vectors_by_position, add_vectors_by_position, update_vectors_by_position
  from ..base import get_model_zoo_home_dir, get_repo_model_zoo_url, get_model_zoo_checksum_dir
  from ..layers import PositionalEmbedding, 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 gen_self_attn_mask
  from ..data.tokenizers import HuggingFaceWordPieceTokenizer
label_desc: Use image node_id 3 for calling the ElectraModel obj's underlying member method code with example usage: obj.forward(inputs, token_types, valid_length) and returns: unknown