docstr: truncate the inputs with balance, number of cut tokens is proportional to the part's length.
          
docstr_tok: ["truncate","the","inputs","with","balance",",","number","of","cut","tokens","is","proportional","to","the","part","'s","length","."]
code: def balanced_truncate(
      input_dict: Dict, num_tokens_to_truncate: int = 0
  ) -> Dict:
      """truncate the inputs with balance, number of cut tokens is proportional to the part's length."""
      shortenable_lens = [
          len(parts) if parts[0] == 1 else 0
          for parts in input_dict["shortenable_ids"]
      ]
      total_shortenable_len = sum(shortenable_lens)
      num_tokens_to_truncate_each_part = [
          part_len / total_shortenable_len * num_tokens_to_truncate
          for part_len in shortenable_lens
      ]
      round_list(
          num_tokens_to_truncate_each_part, num_tokens_to_truncate
      )
  
      truncated_example = defaultdict(list)
      for key in input_dict:
          parts = input_dict[key]
          for num_tokens_to_truncate_part, part in zip(
              num_tokens_to_truncate_each_part, parts
          ):
              truncated_example[key].append(
                  part[: len(part) - num_tokens_to_truncate_part]
              )
      return truncated_example
  
imports: import itertools
  import warnings
  import torch
  import torch.nn
  from torch.utils.data import Dataset
  from typing import Union, List, Tuple, Dict, Optional
  from transformers.data.processors.utils import InputExample, InputFeatures
  from transformers.tokenization_utils import PreTrainedTokenizer
  from collections import defaultdict
  from openprompt.utils import round_list
  import numpy
label_desc: Use image node_id 6 for calling the TokenizerWrapper obj's underlying member method code with example usage: obj.balanced_truncate(input_dict, num_tokens_to_truncate) and returns: truncated_example