code: def truncate_input_sequence(tokens_a, tokens_b, max_num_tokens):
      while True:
          total_length = len(tokens_a) + len(tokens_b)
          if total_length <= max_num_tokens:
              break
  
          trunc_tokens = (
              tokens_a if len(tokens_a) > len(tokens_b) else tokens_b
          )
          assert len(trunc_tokens) >= 1
  
          # We want to sometimes truncate from the front and sometimes from the
          # back to add more randomness and avoid biases.
          if random.random() < 0.5:
              del trunc_tokens[0]
          else:
              trunc_tokens.pop()
  
imports: from tqdm import tqdm
  from typing import Tuple
  from random import shuffle
  import pickle
  import random
  import numpy
  from pathlib import Path
  from pytorch_pretrained_bert.tokenization import BertTokenizer
label_desc: Use image node_id 1 for calling a global function with example usage: truncate_input_sequence(tokens_a, tokens_b, max_num_tokens) without return types