code: def infer_label_column_type_by_problem_type(
      column_types: Dict,
      label_columns: Union[str, List[str]],
      problem_type: Optional[str],
      data: Optional[pd.DataFrame] = None,
      valid_data: Optional[pd.DataFrame] = None,
      allowable_label_types: Optional[List[str]] = (
          CATEGORICAL,
          NUMERICAL,
          NER_ANNOTATION,
          ROIS,
          SEMANTIC_SEGMENTATION_GT,
      ),
      fallback_label_type: Optional[str] = CATEGORICAL,
  ):
      """
      Infer the label column types based on problem type.
  
      Parameters
      ----------
      column_types
          Types of columns in a pd.DataFrame.
      label_columns
          The label columns in a pd.DataFrame.
      problem_type
          Type of problem.
      data
          A pd.DataFrame.
      valid_data
          A validation pd.DataFrame.
      allowable_label_types
          Which label types are allowed.
      fallback_label_type
          If a label type is not within the allowable_label_types, replace it with this fallback_label_type.
  
      Returns
      -------
      Column types with the label columns' types inferred from the problem type.
      """
      if label_columns is None:
          return column_types
  
      if isinstance(label_columns, str):
          label_columns = [label_columns]
  
      for col_name in label_columns:
          # For zero-shot inference, label column is unnecessary
          if col_name not in column_types:
              continue
          if data is not None:
              check_missing_values(
                  data=data, column_name=col_name, split="training"
              )
          if valid_data is not None:
              check_missing_values(
                  data=valid_data,
                  column_name=col_name,
                  split="validation",
              )
          if column_types[col_name] == NULL:
              raise ValueError(
                  f"Label column '{col_name}' contains only one label class. Make sure it has at least two label classes."
              )
          if problem_type in [MULTICLASS, BINARY, CLASSIFICATION]:
              column_types[col_name] = CATEGORICAL
          elif problem_type == REGRESSION:
              column_types[col_name] = NUMERICAL
          elif problem_type == NER:
              column_types[col_name] = NER_ANNOTATION
          elif problem_type in [
              OBJECT_DETECTION,
              OPEN_VOCABULARY_OBJECT_DETECTION,
          ]:
              column_types[col_name] = ROIS
          elif problem_type == SEMANTIC_SEGMENTATION:
              column_types[col_name] = SEMANTIC_SEGMENTATION_GT
  
          if column_types[col_name] not in allowable_label_types:
              column_types[col_name] = fallback_label_type
  
      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 12 for calling a global function with example usage: infer_label_column_type_by_problem_type(column_types, label_columns, problem_type, data, valid_data, allowable_label_types, fallback_label_type) and returns: column_types, column_types