code: def infer_vegalite_type_for_dfi_column(
      column: Union[Column, "PandasColumn"],
  ) -> Union[InferredVegaLiteType, Tuple[InferredVegaLiteType, list]]:
      from pyarrow.interchange.from_dataframe import column_to_array
  
      try:
          kind = column.dtype[0]
      except NotImplementedError as e:
          # Edge case hack:
          # dtype access fails for pandas column with datetime64[ns, UTC] type,
          # but all we need to know is that its temporal, so check the
          # error message for the presence of datetime64.
          #
          # See https://github.com/pandas-dev/pandas/issues/54239
          if "datetime64" in e.args[0] or "timestamp" in e.args[0]:
              return "temporal"
          raise e
  
      if (
          kind == DtypeKind.CATEGORICAL
          and column.describe_categorical["is_ordered"]
          and column.describe_categorical["categories"] is not None
      ):
          # Treat ordered categorical column as Vega-Lite ordinal
          categories_column = column.describe_categorical["categories"]
          categories_array = column_to_array(categories_column)
          return "ordinal", categories_array.to_pylist()
      if kind in (
          DtypeKind.STRING,
          DtypeKind.CATEGORICAL,
          DtypeKind.BOOL,
      ):
          return "nominal"
      elif kind in (DtypeKind.INT, DtypeKind.UINT, DtypeKind.FLOAT):
          return "quantitative"
      elif kind == DtypeKind.DATETIME:
          return "temporal"
      else:
          raise ValueError(f"Unexpected DtypeKind: {kind}")
  
imports: from collections.abc import Mapping, MutableMapping
  from copy import deepcopy
  import json
  import itertools
  import re
  import sys
  import traceback
  import warnings
  from typing import Callable, TypeVar, Any, Union, Dict, Optional, Tuple, Sequence, Type, cast
  from types import ModuleType
  import jsonschema
  import pandas
  import numpy
  from pandas.api.types import infer_dtype
  from altair.utils.schemapi import SchemaBase
  from altair.utils._dfi_types import Column, DtypeKind, DataFrame
  from typing import Literal, Protocol, TYPE_CHECKING
label_desc: Use image node_id 8 for calling a global function with example usage: infer_vegalite_type_for_dfi_column(column) and returns: str,  categories_array, str, str, str, str