code: def get_text_token_max_len(
      provided_max_len, config, tokenizer, checkpoint_name
  ):
      """
      Compute the allowable max length of token sequences.
  
      Parameters
      ----------
      provided_max_len
          The provided max length.
      config
          Model config.
      tokenizer
          Text tokenizer.
      checkpoint_name
          Name of checkpoint.
  
      Returns
      -------
      Token sequence max length.
      """
      if (
          hasattr(config, "relative_attention")
          and config.relative_attention
      ):
          default_max_len = tokenizer.model_max_length
      elif (
          hasattr(config, "position_embedding_type")
          and "relative" in config.position_embedding_type
      ):
          default_max_len = tokenizer.model_max_length
      elif hasattr(config, "max_position_embeddings"):
          default_max_len = config.max_position_embeddings
      else:
          default_max_len = tokenizer.model_max_length
  
      if provided_max_len is None or provided_max_len <= 0:
          max_len = default_max_len
      else:
          if provided_max_len < default_max_len:
              if (
                  default_max_len < 10**6
              ):  # Larger than this value usually means infinite.
                  warnings.warn(
                      f"provided max length: {provided_max_len} "
                      f"is smaller than {checkpoint_name}'s default: {default_max_len}"
                  )
          max_len = min(provided_max_len, default_max_len)
  
      return max_len
  
imports: import ast
  import codecs
  import copy
  import re
  import warnings
  from io import BytesIO
  from typing import Callable, Dict, Iterable, List, Optional, Tuple, Union
  import numpy
  import pandas
  import PIL
  from omegaconf import ListConfig
  from text_unidecode import unidecode
  from timm.data.constants import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD, IMAGENET_INCEPTION_MEAN, IMAGENET_INCEPTION_STD
  from tokenizers import pre_tokenizers
  from torchvision import transforms
  from ..constants import CLIP_IMAGE_MEAN, CLIP_IMAGE_STD, IDENTIFIER, IMAGE, IMAGE_BYTEARRAY, IMAGE_PATH, MMDET_IMAGE, MMLAB_MODELS
  from .collator import DictCollator
  from .preprocess_dataframe import MultiModalFeaturePreprocessor
  from .randaug import RandAugment
  from .trivial_augmenter import TrivialAugment
label_desc: Use image node_id 12 for calling a global function with example usage: get_text_token_max_len(provided_max_len, config, tokenizer, checkpoint_name) and returns: max_len