class_docstr: An integrated model combined with a generator and a discriminator.  Generator here
  produces a corrupted tokens playing as fake data to fool a discriminator whose
  objective is to distinguish whether each token in the input sentence it accepts
  is the same as the original. It is a classification task instead of prediction
  task as other pretrained models such as bert.
class_docstr_tok: ["An","integrated","model","combined","with","a","generator","and","a","discriminator",".","Generator","here","produces","a","corrupted","tokens","playing","as","fake","data","to","fool","a","discriminator","whose","objective","is","to","distinguish","whether","each","token","in","the","input","sentence","it","accepts","is","the","same","as","the","original",".","It","is","a","classification","task","instead","of","prediction","task","as","other","pretrained","models","such","as","bert","."]
docstr: Sample from the generator to create corrupted input.
  
  Parameters
  ----------
  inputs
      The masked input
  
      - layout = 'NT'
          Shape (batch_size, seq_length)
      - layout = 'TN'
          Shape (seq_length, batch_size)
  
  original_tokens
      The original tokens that appear in the unmasked input sequence
      Shape (batch_size, num_masked_positions).
  masked_positions
      The masked position of the sequence
      Shape (batch_size, num_masked_positions).
  logits
      The logits of each tokens
      Shape (batch_size, num_masked_positions, vocab_size)
  
  Returns
  -------
  corrupted_tokens
      Shape (batch_size, )
  fake_data
      - layout = 'NT'
          Shape (batch_size, seq_length)
      - layout = 'TN'
          Shape (seq_length, batch_size)
  
  labels
      - layout = 'NT'
          Shape (batch_size, seq_length)
      - layout = 'TN'
          Shape (seq_length, batch_size)
docstr_tok: ["Sample","from","the","generator","to","create","corrupted","input",".","Parameters","--","--","--","--","--","inputs","The","masked","input","-","layout","=","'NT'","Shape","(","batch_size",",","seq_length",")","-","layout","=","'TN'","Shape","(","seq_length",",","batch_size",")","original_tokens","The","original","tokens","that","appear","in","the","unmasked","input","sequence","Shape","(","batch_size",",","num_masked_positions",")",".","masked_positions","The","masked","position","of","the","sequence","Shape","(","batch_size",",","num_masked_positions",")",".","logits","The","logits","of","each","tokens","Shape","(","batch_size",",","num_masked_positions",",","vocab_size",")","Returns","--","--","--","-","corrupted_tokens","Shape","(","batch_size",",",")","fake_data","-","layout","=","'NT'","Shape","(","batch_size",",","seq_length",")","-","layout","=","'TN'","Shape","(","seq_length",",","batch_size",")","labels","-","layout","=","'NT'","Shape","(","batch_size",",","seq_length",")","-","layout","=","'TN'","Shape","(","seq_length",",","batch_size",")"]
code: def get_corrupted_tokens(
      self, inputs, original_tokens, masked_positions, logits
  ):
      """
      Sample from the generator to create corrupted input.
  
      Parameters
      ----------
      inputs
          The masked input
  
          - layout = 'NT'
              Shape (batch_size, seq_length)
          - layout = 'TN'
              Shape (seq_length, batch_size)
  
      original_tokens
          The original tokens that appear in the unmasked input sequence
          Shape (batch_size, num_masked_positions).
      masked_positions
          The masked position of the sequence
          Shape (batch_size, num_masked_positions).
      logits
          The logits of each tokens
          Shape (batch_size, num_masked_positions, vocab_size)
  
      Returns
      -------
      corrupted_tokens
          Shape (batch_size, )
      fake_data
          - layout = 'NT'
              Shape (batch_size, seq_length)
          - layout = 'TN'
              Shape (seq_length, batch_size)
  
      labels
          - layout = 'NT'
              Shape (batch_size, seq_length)
          - layout = 'TN'
              Shape (seq_length, batch_size)
  
      """
  
      if self._disallow_correct:
          # TODO(sxjscience), Revise the implementation
          disallow = npx.one_hot(
              masked_positions, depth=self.vocab_size, dtype=self._dtype
          )
          logits = logits - 1000.0 * disallow
      # gumbel_softmax() samples from the logits with a noise of Gumbel distribution
      prob = gumbel_softmax(
          logits,
          temperature=self._temperature,
          eps=self._gumbel_eps,
          use_np_gumbel=False,
      )
      corrupted_tokens = np.argmax(prob, axis=-1).astype(np.int32)
  
      if self.disc_backbone.layout == "TN":
          inputs = inputs.T
      original_data = update_vectors_by_position(
          inputs, original_tokens, masked_positions
      )
      fake_data = update_vectors_by_position(
          inputs, corrupted_tokens, masked_positions
      )
      updates_mask = add_vectors_by_position(
          np.zeros_like(inputs),
          np.ones_like(masked_positions),
          masked_positions,
      )
      # Dealing with multiple zeros in masked_positions which
      # results in a non-zero value in the first index [CLS]
      updates_mask = np.minimum(updates_mask, 1)
      labels = updates_mask * np.not_equal(fake_data, original_data)
      if self.disc_backbone.layout == "TN":
          return corrupted_tokens, fake_data.T, labels.T
      else:
          return corrupted_tokens, fake_data, labels
  
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 ElectraForPretrain obj's underlying member method code with example usage: obj.get_corrupted_tokens(inputs, original_tokens, masked_positions, logits) and returns: corrupted_tokens,  fake_data,  labels, corrupted_tokens,  fake_data,  labels