def truncate_seq_pair(tokens_a, tokens_b, max_num_tokens, rng):
while True:<EOL><INDENT>total_length = len(tokens_a) + len(tokens_b)<EOL>if total_length <= max_num_tokens:<EOL><INDENT>break<EOL><DEDENT>trunc_tokens = tokens_a if len(tokens_a) > len(tokens_b) else tokens_b<EOL>assert len(trunc_tokens) >= <NUM_LIT:1><EOL>if rng.random() < <NUM_LIT:0.5>:<EOL><INDENT>del trunc_tokens[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>trunc_tokens.pop()<EOL><DEDENT><DEDENT>
Truncates a pair of sequences to a maximum sequence length.