code: def avg_num_tokens(field: Series) -> int:
      logger.info(
          f"Calculating average number tokens for field {field.name} using sample of 100 rows."
      )
      field_sample = field.head(100).apply(avg_num_tokens_decoder)
  
      unique_entries = field_sample.unique()
      avg_words = round(
          nan_to_num(
              Series(unique_entries).str.split().str.len().mean()
          )
      )
      return avg_words
  
file_path: ludwig/ludwig/utils/automl/utils.py
imports: import bisect
  import logging
  from typing import Dict
  from numpy import nan_to_num
  from pandas import Series
  from ludwig.api_annotations import DeveloperAPI
  from ludwig.constants import BINARY, CATEGORY, COMBINER, CONFIG, HYPEROPT, IMBALANCE_DETECTION_RATIO, NAME, NUMBER, PARAMETERS, SEARCH_ALG, TRAINER, TYPE
  from ludwig.features.feature_registries import get_output_type_registry
  from ludwig.modules.metric_registry import get_metric_objective
  from ludwig.schema.combiners.utils import get_combiner_jsonschema
label_desc: Use image node_id 2 for calling a global function with example usage: avg_num_tokens(field) and returns: avg_words