code: def create_masked_lm_predictions(self, tokens):
      cand_indexes = []
      for i, token in enumerate(tokens):
          if token == "[CLS]" or token == "[SEP]":
              continue
          if (
              self.do_whole_word_mask
              and len(cand_indexes) >= 1
              and token.startswith("##")
          ):
              cand_indexes[-1].append(i)
          else:
              cand_indexes.append([i])
  
          # cand_indexes.append(i)
  
      random.shuffle(cand_indexes)
      output_tokens = list(tokens)
  
      num_to_predict = min(
          self.max_predictions_per_seq,
          max(1, int(round(len(tokens) * self.masked_lm_prob))),
      )
  
      masked_lms = []
      covered_indexes = set()
      for index in cand_indexes:
          if len(masked_lms) >= num_to_predict:
              break
          if index in covered_indexes:
              continue
          covered_indexes.add(index)
  
          masked_token = None
          # 80% mask
          if random.random() < 0.8:
              masked_token = "[MASK]"
          else:
              # 10% Keep Original
              if random.random() < 0.5:
                  masked_token = tokens[index]
              # 10% replace w/ random word
              else:
                  masked_token = self.vocab_words[
                      random.randint(0, len(self.vocab_words) - 1)
                  ]
  
          output_tokens[index] = masked_token
          masked_lms.append(
              MaskedLMInstance(index=index, label=tokens[index])
          )
  
      masked_lms = sorted(masked_lms, key=lambda x: x.index)
      masked_lm_output = [-1] * len(output_tokens)
      for p in masked_lms:
          masked_lm_output[p.index] = self.tokenizer.vocab[p.label]
  
      return (output_tokens, masked_lm_output)
  
file_path: ColossalAI/examples/community/roberta/preprocessing/get_mask.py
imports: import collections
  import logging
  import random
  import jieba
  import re
  import mask
  import numpy
label_desc: Use image node_id 4 for calling the PreTrainingDataset obj's underlying member method code with example usage: obj.create_masked_lm_predictions(tokens) and returns: output_tokens,  masked_lm_output