code: def is_image_column(
      data: pd.Series,
      col_name: str,
      image_type: str,
      sample_n: Optional[int] = 500,
  ) -> bool:
      """
      Identify if a column is one image-path column.
      Here it counts the failures when trying PIL.Image.open() on a sampled subset.
      If over 90% attempts fail, this column isn't an image-path column.
  
      Parameters
      ----------
      data
          One column of a multimodal pd.DataFrame for training.
      col_name
          Name of column.
      image_type
          The image type to check.
      sample_n
          Number of sample images to open for sanity check.
  
      Returns
      -------
      Whether the column is an image-path column.
      """
      sample_num = min(len(data), sample_n)
      data = data.sample(n=sample_num, random_state=0)
      if image_type == IMAGE_PATH:
          data = data.apply(lambda ele: str(ele).split(";")).tolist()
      elif image_type == IMAGE_BYTEARRAY:
          data = data.tolist()
      else:
          raise ValueError(f"Unsupported image type: {image_type}")
  
      failure_count = 0
      for images in data:
          success = False
          if not isinstance(images, list):
              images = [images]
          for per_image in images:
              try:
                  if image_type == IMAGE_PATH:
                      with PIL.Image.open(per_image) as img:
                          pass
                  elif image_type == IMAGE_BYTEARRAY:
                      with PIL.Image.open(BytesIO(per_image)) as img:
                          pass
                  else:
                      raise ValueError(
                          f"Unsupported image type: {image_type}"
                      )
              except:
                  success = False
                  break
  
              success = True
          if not success:
              failure_count += 1
      failure_ratio = failure_count / sample_num
      # Tolerate high failure rate in case that many image files may be corrupted.
      if failure_ratio <= 0.9:
          if failure_ratio > 0:
              warnings.warn(
                  f"Among {sample_num} sampled images in column '{col_name}', "
                  f"{failure_ratio:.0%} images can't be open. "
                  "You may need to thoroughly check your data to see the percentage of missing images, "
                  "and estimate the potential influence. By default, we skip the samples with missing images. "
                  "You can also set hyperparameter 'data.image.missing_value_strategy' to be 'zero', "
                  "which uses a zero image to replace any missing image.",
                  UserWarning,
              )
          return True
      else:
          return False
  
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 4 for calling a global function with example usage: is_image_column(data, col_name, image_type, sample_n) and returns: True, False