docstr: Parameters
  ----------
  units
      The number of units
  hidden_size
      The hidden size
  num_layers
      Number of layers
  num_heads
      Number of heads
  attention_dropout_prob
      Dropout probability of the attention layer
  hidden_dropout_prob
      Dropout probability
  output_attention
      Whether to output the attention weights
  dtype
      Data type of the weights
  output_all_encodings
  layer_norm_eps
  weight_initializer
  bias_initializer
  activation
  layout
docstr_tok: ["Parameters","--","--","--","--","--","units","The","number","of","units","hidden_size","The","hidden","size","num_layers","Number","of","layers","num_heads","Number","of","heads","attention_dropout_prob","Dropout","probability","of","the","attention","layer","hidden_dropout_prob","Dropout","probability","output_attention","Whether","to","output","the","attention","weights","dtype","Data","type","of","the","weights","output_all_encodings","layer_norm_eps","weight_initializer","bias_initializer","activation","layout"]
code: def __init__(
      self,
      units=512,
      hidden_size=2048,
      num_layers=6,
      num_heads=8,
      attention_dropout_prob=0.0,
      hidden_dropout_prob=0.0,
      output_attention=False,
      dtype="float32",
      output_all_encodings=False,
      layer_norm_eps=1e-12,
      weight_initializer=TruncNorm(stdev=0.02),
      bias_initializer="zeros",
      activation="gelu",
      layout="NT",
  ):
      """
  
      Parameters
      ----------
      units
          The number of units
      hidden_size
          The hidden size
      num_layers
          Number of layers
      num_heads
          Number of heads
      attention_dropout_prob
          Dropout probability of the attention layer
      hidden_dropout_prob
          Dropout probability
      output_attention
          Whether to output the attention weights
      dtype
          Data type of the weights
      output_all_encodings
      layer_norm_eps
      weight_initializer
      bias_initializer
      activation
      layout
      """
      super().__init__()
      assert units % num_heads == 0, (
          "In ElectraEncoder, The units should be divisible "
          "by the number of heads. Received units={}, num_heads={}".format(
              units, num_heads
          )
      )
  
      self._dtype = dtype
      self._layout = layout
      self._num_layers = num_layers
  
      self._output_attention = output_attention
      self._output_all_encodings = output_all_encodings
  
      self.all_encoder_layers = nn.HybridSequential()
      for layer_idx in range(num_layers):
          self.all_encoder_layers.add(
              TransformerEncoderLayer(
                  units=units,
                  hidden_size=hidden_size,
                  num_heads=num_heads,
                  attention_dropout_prob=attention_dropout_prob,
                  hidden_dropout_prob=hidden_dropout_prob,
                  layer_norm_eps=layer_norm_eps,
                  weight_initializer=weight_initializer,
                  bias_initializer=bias_initializer,
                  activation=activation,
                  dtype=dtype,
                  layout=layout,
              )
          )
  
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 1 to create a new ElectraEncoder object from inherited base classes: HybridBlock with example: obj = ElectraEncoder(units, hidden_size, num_layers, num_heads, attention_dropout_prob, hidden_dropout_prob, output_attention, dtype, output_all_encodings, layer_norm_eps, weight_initializer, bias_initializer, activation, layout)