def truncate_seq_pair(tokens_a: Union[(List[int], List[str])], tokens_b: Union[(List[int], List[str])], max_length: int):
    "Truncates a sequence pair in place to the maximum length.\n\n    This is a simple heuristic which will always truncate the longer sequence\n    one token at a time. This makes more sense than truncating an equal\n    percent of tokens from each, since if one sequence is very short then\n    each token that's truncated likely contains more information than a\n    longer sequence.\n\n    Example:\n\n    .. code-block:: python\n\n        tokens_a = [1, 2, 3, 4, 5]\n        tokens_b = [6, 7]\n        truncate_seq_pair(tokens_a, tokens_b, 5)\n        tokens_a  # [1, 2, 3]\n        tokens_b  # [6, 7]\n\n    Args:\n        tokens_a: A list of tokens or token ids.\n        tokens_b: A list of tokens or token ids.\n        max_length: maximum sequence length.\n    "
    while True:
        total_length = (len(tokens_a) + len(tokens_b))
        if (total_length <= max_length):
            break
        if (len(tokens_a) > len(tokens_b)):
            tokens_a.pop()
        else:
            tokens_b.pop()
Truncates a sequence pair in place to the maximum length.

This is a simple heuristic which will always truncate the longer sequence
one token at a time. This makes more sense than truncating an equal
percent of tokens from each, since if one sequence is very short then
each token that's truncated likely contains more information than a
longer sequence.

Example:

.. code-block:: python

    tokens_a = [1, 2, 3, 4, 5]
    tokens_b = [6, 7]
    truncate_seq_pair(tokens_a, tokens_b, 5)
    tokens_a  # [1, 2, 3]
    tokens_b  # [6, 7]

Args:
    tokens_a: A list of tokens or token ids.
    tokens_b: A list of tokens or token ids.
    max_length: maximum sequence length.
def truncate_seq_pair(tokens_a: Union[(List[int], List[str])], tokens_b: Union[(List[int], List[str])], max_length: int):
    "Truncates a sequence pair in place to the maximum length.\n\n    This is a simple heuristic which will always truncate the longer sequence\n    one token at a time. This makes more sense than truncating an equal\n    percent of tokens from each, since if one sequence is very short then\n    each token that's truncated likely contains more information than a\n    longer sequence.\n\n    Example:\n\n    .. code-block:: python\n\n        tokens_a = [1, 2, 3, 4, 5]\n        tokens_b = [6, 7]\n        truncate_seq_pair(tokens_a, tokens_b, 5)\n        tokens_a  # [1, 2, 3]\n        tokens_b  # [6, 7]\n\n    Args:\n        tokens_a: A list of tokens or token ids.\n        tokens_b: A list of tokens or token ids.\n        max_length: maximum sequence length.\n    "
    while True:
        total_length = (len(tokens_a) + len(tokens_b))
        if (total_length <= max_length):
            break
        if (len(tokens_a) > len(tokens_b)):
            tokens_a.pop()
        else:
            tokens_b.pop()