def sample_thief_data(thief_data,
                      threshold=50,
                      sanitize=False,
                      vocab=None,
                      vocab_dict=None):
  """Sample sentences from thief dataset. Remove OOV if sanitize is True."""
  thief_sample = random.choice(thief_data)
  while len(thief_sample.split()) > threshold:
    thief_sample = random.choice(thief_data)

  if sanitize:
    thief_sample_words = thief_sample.split()
    sanitized_thief_sample_words = sanitize_sentence(
        sample_tokens=thief_sample_words, vocab=vocab, vocab_dict=vocab_dict)
    return " ".join(sanitized_thief_sample_words)
  else:
    return thief_sample
Sample sentences from thief dataset. Remove OOV if sanitize is True.
language/bert_extraction/steal_bert_classifier/data_generation/preprocess_util.py