code: def truncate_segments(
      tokens_a, tokens_b, len_a, len_b, max_num_tokens, np_rng
  ):
      """Truncates a pair of sequences to a maximum sequence length."""
      # print(len_a, len_b, max_num_tokens)
      assert len_a > 0
      if len_a + len_b <= max_num_tokens:
          return False
      while len_a + len_b > max_num_tokens:
          if len_a > len_b:
              len_a -= 1
              tokens = tokens_a
          else:
              len_b -= 1
              tokens = tokens_b
          if np_rng.random() < 0.5:
              del tokens[0]
          else:
              tokens.pop()
      return True
  
imports: import collections
  import os
  import subprocess
  import time
  from typing import Any
  import numpy
  import torch
  from omegaconf import OmegaConf
  from omegaconf.dictconfig import DictConfig
  from nemo.collections.nlp.data.language_modeling.megatron.base_dataset_utils import get_datasets_weights_and_num_samples, get_train_valid_test_split_
  from nemo.collections.nlp.data.language_modeling.megatron.blendable_dataset import BlendableDataset
  from nemo.collections.nlp.data.language_modeling.megatron.indexed_dataset import deallocate_indexed_dataset_memory
  from nemo.collections.nlp.data.language_modeling.megatron.indexed_dataset import make_dataset
  from nemo.collections.nlp.data.language_modeling.megatron.indexed_dataset import make_indexed_dataset_compatibility
  from nemo.collections.nlp.data.language_modeling.megatron.length_distribution_type import LengthDistribution
  from nemo.collections.nlp.data.language_modeling.megatron.lm_adapted_t5_dataset import T5LMAdaptedDataset
  from nemo.utils import logging
  from nemo.utils.get_rank import is_global_rank_zero
label_desc: Use image node_id 3 for calling a global function with example usage: truncate_segments(tokens_a, tokens_b, len_a, len_b, max_num_tokens, np_rng) and returns: True, False