code: def _get_text_feature_max_length(
      config, training_set_metadata
  ) -> int:
      """Returns max sequence length over text features, subject to preprocessing limit."""
      max_length = 0
      for feature in config["input_features"]:
          if feature["type"] == TEXT:
              feature_max_len = training_set_metadata[feature["name"]][
                  "max_sequence_length"
              ]
              if feature_max_len > max_length:
                  max_length = feature_max_len
      if (
          ("preprocessing" in config)
          and (TEXT in config["preprocessing"])
          and ("max_sequence_length" in config["preprocessing"][TEXT])
      ):
          limit = config["preprocessing"][TEXT]["max_sequence_length"]
      else:
          limit = 256  # Preprocessing default max_sequence_length = 256
      if max_length > limit + 2:  # For start and stop symbols.
          max_length = limit + 2
      return max_length
  
imports: import copy
  import logging
  import math
  from collections import OrderedDict
  from typing import List
  import psutil
  from ludwig.api import LudwigModel
  from ludwig.backend import initialize_backend
  from ludwig.constants import AUTO, AUTOML_DEFAULT_TEXT_ENCODER, AUTOML_LARGE_TEXT_DATASET, AUTOML_MAX_ROWS_PER_CHECKPOINT, AUTOML_SMALLER_TEXT_ENCODER, AUTOML_SMALLER_TEXT_LENGTH, AUTOML_TEXT_ENCODER_MAX_TOKEN_LEN, HYPEROPT, MINIMUM_BATCH_SIZE, PREPROCESSING, SPACE, TEXT, TRAINER
  from ludwig.data.preprocessing import preprocess_for_training
  from ludwig.features.feature_registries import update_config_with_metadata
  from ludwig.schema.model_config import ModelConfig
  from ludwig.utils.automl.utils import get_model_type
  from ludwig.utils.torch_utils import initialize_pytorch
label_desc: Use image node_id 3 for calling a global function with example usage: _get_text_feature_max_length(config, training_set_metadata) and returns: max_length