class_docstr: Prepare text data for the model specified by "prefix". For multiple models requiring text data,
  we need to create a TextProcessor for each related model so that they will have independent input.
class_docstr_tok: ["Prepare","text","data","for","the","model","specified","by","``","prefix","''",".","For","multiple","models","requiring","text","data",",","we","need","to","create","a","TextProcessor","for","each","related","model","so","that","they","will","have","independent","input","."]
docstr: Get the trimmed lengths of multiple text token sequences. It will make sure that
  the trimmed length is smaller than or equal to the max_length.
  - do_merge is True
      Make sure that sum(trimmed_lengths) <= max_length.
      The strategy is always trying to trim the longer lengths.
  - do_merge is False
      Make sure that all(trimmed_lengths <= max_length).
  
  Parameters
  ----------
  lengths
      The original lengths of each token sequence.
  max_length
      When do_merge is True,
          We set the max_length constraint on the total length.
      When do_merge is False,
          We set the max_length constraint on individual sequences.
  do_merge
      Whether these sentences will be merged.
  
  Returns
  -------
  trimmed_lengths
      The trimmed lengths of each individual text field.
docstr_tok: ["Get","the","trimmed","lengths","of","multiple","text","token","sequences",".","It","will","make","sure","that","the","trimmed","length","is","smaller","than","or","equal","to","the","max_length",".","-","do_merge","is","True","Make","sure","that","sum","(","trimmed_lengths",")","<","=","max_length",".","The","strategy","is","always","trying","to","trim","the","longer","lengths",".","-","do_merge","is","False","Make","sure","that","all","(","trimmed_lengths","<","=","max_length",")",".","Parameters","--","--","--","--","--","lengths","The","original","lengths","of","each","token","sequence",".","max_length","When","do_merge","is","True",",","We","set","the","max_length","constraint","on","the","total","length",".","When","do_merge","is","False",",","We","set","the","max_length","constraint","on","individual","sequences",".","do_merge","Whether","these","sentences","will","be","merged",".","Returns","--","--","--","-","trimmed_lengths","The","trimmed","lengths","of","each","individual","text","field","."]
code: def get_trimmed_lengths(
      lengths: List[int],
      max_length: int,
      do_merge: bool = False,
  ) -> List:
      """
      Get the trimmed lengths of multiple text token sequences. It will make sure that
      the trimmed length is smaller than or equal to the max_length.
      - do_merge is True
          Make sure that sum(trimmed_lengths) <= max_length.
          The strategy is always trying to trim the longer lengths.
      - do_merge is False
          Make sure that all(trimmed_lengths <= max_length).
  
      Parameters
      ----------
      lengths
          The original lengths of each token sequence.
      max_length
          When do_merge is True,
              We set the max_length constraint on the total length.
          When do_merge is False,
              We set the max_length constraint on individual sequences.
      do_merge
          Whether these sentences will be merged.
  
      Returns
      -------
      trimmed_lengths
          The trimmed lengths of each individual text field.
      """
      lengths = np.array(lengths)
      if do_merge:
          total_length = sum(lengths)
          if total_length <= max_length:
              return list(lengths)
          trimmed_lengths = np.zeros_like(lengths)
          while sum(trimmed_lengths) != max_length:
              remainder = max_length - sum(trimmed_lengths)
              budgets = lengths - trimmed_lengths
              nonzero_idx = (budgets > 0).nonzero()[0]
              nonzero_budgets = budgets[nonzero_idx]
              if remainder < len(nonzero_idx):
                  for i in range(remainder):
                      trimmed_lengths[nonzero_idx[i]] += 1
              else:
                  increment = min(
                      min(nonzero_budgets),
                      remainder // len(nonzero_idx),
                  )
                  trimmed_lengths[nonzero_idx] += increment
          return list(trimmed_lengths)
      else:
          return list(np.minimum(lengths, max_length))
  
imports: import ast
  import logging
  import os
  import warnings
  from copy import deepcopy
  from typing import Any, Dict, List, Optional, Union
  import numpy
  from nptyping import NDArray
  from omegaconf import DictConfig
  from torch import nn
  from ..constants import CHOICES_IDS, COLUMN, TEXT, TEXT_SEGMENT_IDS, TEXT_TOKEN_IDS, TEXT_VALID_LENGTH
  from .collator import PadCollator, StackCollator
  from .template_engine import TemplateEngine
  from .trivial_augmenter import TrivialAugment
  from .utils import extract_value_from_config, get_text_token_max_len, normalize_txt, register_encoding_decoding_error_handlers
label_desc: Use image node_id 11 for calling the TextProcessor obj's underlying member method code with example usage: obj.get_trimmed_lengths(lengths, max_length, do_merge) and returns: list, list, list