code: def _get_x_encoding(
      df: pd.DataFrame,
      x_column: str | None,
      x_from_user: str | None,
      chart_type: ChartType,
  ) -> alt.X:
      import altair as alt
  
      if x_column is None:
          # If no field is specified, the full axis disappears when no data is present.
          # Maybe a bug in vega-lite? So we pass a field that doesn't exist.
          x_field = NON_EXISTENT_COLUMN_NAME
          x_title = ""
      elif x_column == SEPARATED_INDEX_COLUMN_NAME:
          # If the x column name is the crazy anti-collision name we gave it, then need to set
          # up a title so we never show the crazy name to the user.
          x_field = x_column
          # Don't show a label in the x axis (not even a nice label like
          # SEPARATED_INDEX_COLUMN_TITLE) when we pull the x axis from the index.
          x_title = ""
      else:
          x_field = x_column
  
          # Only show a label in the x axis if the user passed a column explicitly. We
          # could go either way here, but I'm keeping this to avoid breaking the existing
          # behavior.
          if x_from_user is None:
              x_title = ""
          else:
              x_title = x_column
  
      return alt.X(
          x_field,
          title=x_title,
          type=_get_x_encoding_type(df, chart_type, x_column),
          scale=_get_scale(df, x_column),
          axis=_get_axis_config(df, x_column, grid=False),
      )
  
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 16 for calling a global function with example usage: _get_x_encoding(df, x_column, x_from_user, chart_type) and returns: alt