code: def infer_column_types(
      data: pd.DataFrame,
      valid_data: Optional[pd.DataFrame] = None,
      label_columns: Union[str, List[str]] = None,
      provided_column_types: Optional[Dict] = None,
      allowable_column_types: Optional[List[str]] = None,
      fallback_column_type: Optional[str] = None,
      id_mappings: Optional[
          Union[Dict[str, Dict], Dict[str, pd.Series]]
      ] = None,
      problem_type: Optional[str] = None,
  ) -> Dict:
      """
      Infer the column types of a multimodal pd.DataFrame.
  
      Parameters
      ----------
      data
          The multimodal pd.DataFrame for training.
      valid_data
          The multimodal pd.DataFrame for validation.
      label_columns
          The label column names.
      provided_column_types
          Additional dictionary that you can use to specify the columns types that you know.
          {'col_name': TYPE, ...}
      allowable_column_types
          What column types are allowed. This is the prior knowledge inferred from the model type.
      fallback_column_type
          What's the fallback column type if the detected type if out of the allowable_column_types.
      id_mappings
          Id-to-content mappings. The contents can be text, image, etc.
          This is used when the dataframe contains the query/response indexes instead of their contents.
      problem_type
          The problem type used to update some column types.
  
      Returns
      -------
      column_types
          A dictionary containing the mappings from column names to their modality types.
          If the column does not contain any useful information, we will set its column type NULL.
      """
      if label_columns is None:
          label_columns = []
      if isinstance(label_columns, str):
          label_columns = [label_columns]
  
      column_types = collections.OrderedDict()
  
      if valid_data is None:
          valid_data = data
          is_training = False
      else:
          is_training = True
  
      id_mappings_types = infer_id_mappings_types(id_mappings)
  
      for col_name in data.columns:
          if (
              provided_column_types is not None
              and col_name in provided_column_types
          ):
              column_types[col_name] = provided_column_types[col_name]
              continue
          # Identify columns that provide no information
          idx = data[col_name].first_valid_index()
          if idx is None:
              # No valid index, thus, we will just ignore the column
              column_types[col_name] = NULL
              continue
          if (
              (
                  not isinstance(
                      data[col_name][idx], (list, dict, set, bytearray)
                  )
              )
              and len(data[col_name].unique()) == 1
              and is_training
          ):
              column_types[col_name] = NULL
              continue
          # TODO: valid check for collections
  
          if is_rois_column(data[col_name]):
              column_types[col_name] = ROIS
          # keep the elif here because ROIS need to skip the categorical check
          # where error occurs due to List type input
          elif is_identifier_column(
              data[col_name], col_name=col_name, id_mappings=id_mappings
          ):
              column_types[
                  col_name
              ] = f"{id_mappings_types[col_name]}_{IDENTIFIER}"
          elif is_categorical_column(
              data[col_name],
              valid_data[col_name],
              is_label=col_name in label_columns,
          ):  # Infer categorical column
              column_types[col_name] = CATEGORICAL
          elif is_numerical_column(
              data[col_name], valid_data[col_name]
          ):  # Infer numerical column
              column_types[col_name] = NUMERICAL
          elif is_image_column(
              data[col_name], col_name=col_name, image_type=IMAGE_PATH
          ):  # Infer image-path column
              # Check if it is document image or not.
              if is_document_image_column(
                  data[col_name], col_name=col_name
              ):
                  column_types[col_name] = DOCUMENT_IMAGE
              elif problem_type == SEMANTIC_SEGMENTATION:
                  column_types[col_name] = SEMANTIC_SEGMENTATION_IMG
              else:
                  column_types[col_name] = IMAGE_PATH
          elif is_document_pdf_column(
              data[col_name], col_name=col_name
          ):
              column_types[col_name] = DOCUMENT_PDF
          elif is_text_column(data[col_name]):  # Infer text column
              column_types[col_name] = TEXT
          elif is_image_column(
              data[col_name],
              col_name=col_name,
              image_type=IMAGE_BYTEARRAY,
          ):  # Infer image-bytearray column
              column_types[col_name] = IMAGE_BYTEARRAY
          else:  # All the other columns are treated as categorical
              column_types[col_name] = CATEGORICAL
  
      if allowable_column_types and fallback_column_type:
          column_types = set_fallback_column_type(
              column_types=column_types,
              allowable_column_types=allowable_column_types,
              fallback_column_type=fallback_column_type,
          )
      if problem_type == NER:
          column_types = infer_ner_column_type(
              column_types=column_types
          )
  
      if problem_type and label_columns:
          column_types = infer_label_column_type_by_problem_type(
              column_types=column_types,
              label_columns=label_columns,
              problem_type=problem_type,
              data=data,
              valid_data=valid_data if is_training else None,
          )
  
      return column_types
  
imports: import collections
  import json
  import logging
  import warnings
  from io import BytesIO
  from typing import Dict, List, Optional, Tuple, Union
  import pandas
  import PIL
  import pytesseract
  from autogluon.core.utils import infer_problem_type
  from ..constants import BINARY, CATEGORICAL, CLASSIFICATION, DOCUMENT_IMAGE, DOCUMENT_PDF, IDENTIFIER, IMAGE, IMAGE_BYTEARRAY, IMAGE_PATH, MULTICLASS, NER, NER_ANNOTATION, NULL, NUMERICAL, OBJECT_DETECTION, OPEN_VOCABULARY_OBJECT_DETECTION, REGRESSION, ROIS, SEMANTIC_SEGMENTATION, SEMANTIC_SEGMENTATION_GT, SEMANTIC_SEGMENTATION_IMG, TEXT, TEXT_NER
  from .utils import is_rois_input
label_desc: Use image node_id 10 for calling a global function with example usage: infer_column_types(data, valid_data, label_columns, provided_column_types, allowable_column_types, fallback_column_type, id_mappings, problem_type) and returns: column_types