def token_add(token_list, vocab, probs, num_changes):
  """Add new tokens at random positions in the original token_list."""
  original_len = len(token_list)
  for _ in range(num_changes):
    random_index = random.randint(0, len(token_list))
    token_list.insert(random_index, sample_next_token(vocab, probs, "_uniform"))
  assert len(token_list) == original_len + num_changes
  return token_list
Add new tokens at random positions in the original token_list.
language/bert_extraction/steal_bert_classifier/data_generation/preprocess_util.py