def truncate_paragraph(paragraph, max_num_tokens, rng):
  """Truncates a 5 sequences to a maximum sequence length."""
  while True:
    total_length = sum([len(p) for p in paragraph])
    if total_length <= max_num_tokens:
      break

    max_index = paragraph.index(max(paragraph))
    assert len(paragraph[max_index]) >= 1

    # We want to sometimes truncate from the front and sometimes from the
    # back to add more randomness and avoid biases.
    if rng.random() < 0.5:
      del paragraph[max_index][0]
    else:
      paragraph[max_index].pop()
Truncates a 5 sequences to a maximum sequence length.
language/conpono/create_pretrain_data/preprocessing_utils.py