def create_masked_lm_predictions(tokens, masked_lm_prob,<EOL>max_predictions_per_seq, vocab_words, rng):
cand_indexes = []<EOL>for (i, token) in enumerate(tokens):<EOL><INDENT>if token in ['<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>continue<EOL><DEDENT>cand_indexes.append(i)<EOL><DEDENT>rng.shuffle(cand_indexes)<EOL>output_tokens = list(tokens)<EOL>num_to_predict = min(max_predictions_per_seq,<EOL>max(<NUM_LIT:1>, int(round(len(tokens) * masked_lm_prob))))<EOL>masked_lms = []<EOL>covered_indexes = set()<EOL>for index in cand_indexes:<EOL><INDENT>if len(masked_lms) >= num_to_predict:<EOL><INDENT>break<EOL><DEDENT>if index in covered_indexes:<EOL><INDENT>continue<EOL><DEDENT>covered_indexes.add(index)<EOL>masked_token = None<EOL>if rng.random() < <NUM_LIT>:<EOL><INDENT>masked_token = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>if rng.random() < <NUM_LIT:0.5>:<EOL><INDENT>masked_token = tokens[index]<EOL><DEDENT>else:<EOL><INDENT>masked_token = vocab_words[rng.randint(<NUM_LIT:0>,<EOL>len(vocab_words) - <NUM_LIT:1>)]<EOL><DEDENT><DEDENT>output_tokens[index] = masked_token<EOL>masked_lms.append(MaskedLmInstance(index=index, label=tokens[index]))<EOL><DEDENT>masked_lms = sorted(masked_lms, key=lambda x: x.index)<EOL>masked_lm_positions = []<EOL>masked_lm_labels = []<EOL>for p in masked_lms:<EOL><INDENT>masked_lm_positions.append(p.index)<EOL>masked_lm_labels.append(p.label)<EOL><DEDENT>return (output_tokens, masked_lm_positions, masked_lm_labels)<EOL>
Creates the predictions for the masked LM objective.