code: def _maybe_convert_color_column_in_place(
      df: pd.DataFrame, color_column: str | None
  ):
      """If needed, convert color column to a format Vega understands."""
      if color_column is None or len(df[color_column]) == 0:
          return
  
      first_color_datum = df[color_column][0]
  
      if is_hex_color_like(first_color_datum):
          # Hex is already CSS-valid.
          pass
      elif is_color_tuple_like(first_color_datum):
          # Tuples need to be converted to CSS-valid.
          df[color_column] = df[color_column].map(to_css_color)
      else:
          # Other kinds of colors columns (i.e. pure numbers or nominal strings) shouldn't
          # be converted since they are treated by Vega-Lite as sequential or categorical colors.
          pass
  
imports: from __future__ import annotations
  from contextlib import nullcontext
  from datetime import date
  from enum import Enum
  from typing import TYPE_CHECKING, Any, Collection, Dict, List, Sequence, Tuple, cast
  import pandas
  from pandas.api.types import infer_dtype, is_integer_dtype
  from typing_extensions import Literal
  import streamlit.elements.arrow_vega_lite
  from streamlit import type_util
  from streamlit.color_util import Color, is_color_like, is_color_tuple_like, is_hex_color_like, to_css_color
  from streamlit.elements.altair_utils import AddRowsMetadata
  from streamlit.elements.arrow import Data
  from streamlit.elements.utils import last_index_for_melted_dataframes
  from streamlit.errors import Error, StreamlitAPIException
  from streamlit.proto.ArrowVegaLiteChart_pb2 import ArrowVegaLiteChart
  from streamlit.runtime.metrics_util import gather_metrics
label_desc: Use image node_id 7 for calling a global function with example usage: _maybe_convert_color_column_in_place(df, color_column) without return types