code: def truncate_seq_pair(
      tokens_a: Union[List[int], List[str]],
      tokens_b: Union[List[int], List[str]],
      max_length: int,
  ):
      r"""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.
      """
      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()
  
imports: from typing import List, Union
  import inspect
  import funcsigs
  from pydoc import locate
  import copy
  import collections
  import numpy
  import tensorflow
  from texar.tf.hyperparams import HParams
  from texar.tf.utils.dtypes import is_str, is_callable, compat_as_text, _maybe_list_to_array
label_desc: Use image node_id 30 for calling a global function with example usage: truncate_seq_pair(tokens_a, tokens_b, max_length) without return types