docstr: Prepare masked tokens inputs/labels for masked language modeling: 80% MASK, 10% random, 10% original. 
docstr_tok: ["Prepare","masked","tokens","inputs\/labels","for","masked","language","modeling",":","80","%","MASK",",","10","%","random",",","10","%","original","."]
code: def mask_tokens(
      self, inputs: torch.Tensor, mlm_probability=0.15, pad=True
  ):
      """Prepare masked tokens inputs/labels for masked language modeling: 80% MASK, 10% random, 10% original."""
      labels = inputs.clone()
      # mlm_probability defaults to 0.15 in Bert
      probability_matrix = torch.full(labels.shape, mlm_probability)
      special_tokens_mask = [
          self.tokenizer.get_special_tokens_mask(
              val, already_has_special_tokens=True
          )
          for val in labels.tolist()
      ]
      probability_matrix.masked_fill_(
          torch.tensor(special_tokens_mask, dtype=torch.bool), value=0.0
      )
      if self.tokenizer._pad_token is not None:
          padding_mask = labels.eq(self.tokenizer.pad_token_id)
          probability_matrix.masked_fill_(padding_mask, value=0.0)
      masked_indices = torch.bernoulli(probability_matrix).bool()
      labels[
          ~masked_indices
      ] = -100  # We only compute loss on masked tokens
  
      # 80% of the time, we replace masked input tokens with tokenizer.mask_token ([MASK])
      indices_replaced = (
          torch.bernoulli(torch.full(labels.shape, 0.8)).bool()
          & masked_indices
      )
      inputs[indices_replaced] = self.tokenizer.convert_tokens_to_ids(
          self.tokenizer.mask_token
      )
  
      # 10% of the time, we replace masked input tokens with random word
      indices_random = (
          torch.bernoulli(torch.full(labels.shape, 0.5)).bool()
          & masked_indices
          & ~indices_replaced
      )
      random_words = torch.randint(
          len(self.tokenizer), labels.shape, dtype=torch.long
      )
      inputs[indices_random] = random_words[indices_random]
  
      if pad:
          input_pads = self.tokenizer.max_len - inputs.shape[-1]
          label_pads = self.tokenizer.max_len - labels.shape[-1]
  
          inputs = F.pad(
              inputs,
              pad=(0, input_pads),
              value=self.tokenizer.pad_token_id,
          )
          labels = F.pad(
              labels,
              pad=(0, label_pads),
              value=self.tokenizer.pad_token_id,
          )
  
      # The rest of the time (10% of the time) we keep the masked input tokens unchanged
      return inputs, labels
  
imports: import re
  import torch
  import torch.nn
  import torch.nn.functional
  from torch.utils.data import Dataset, DataLoader, random_split
  from tqdm import tqdm
  from reformer_pytorch import Reformer, ReformerLM
  from transformers import BertTokenizer, PreTrainedTokenizer
  from fairseq.optim.adafactor import Adafactor
  import os
  import json
  import logging
  from datetime import datetime
label_desc: Use image node_id 3 for calling the ReformerTrainer obj's underlying member method code with example usage: obj.mask_tokens(inputs, mlm_probability, pad) and returns: inputs,  labels