def sanitize_sentence(sample_tokens, vocab, vocab_dict):
  """Replace all OOV tokens with random tokens from vocab."""
  sanitized_sample_tokens = []
  for token in sample_tokens:
    if token in vocab_dict:
      sanitized_sample_tokens.append(token)
    else:
      sanitized_sample_tokens.append(random.choice(vocab))
  return sanitized_sample_tokens
Replace all OOV tokens with random tokens from vocab.
language/bert_extraction/steal_bert_classifier/data_generation/preprocess_util.py