code: def _expand_selector_dicts(
      df: DataFrame,
      d: Mapping[Any, Any] | None,
      *,
      expand_keys: bool,
      expand_values: bool,
      tuple_keys: bool = False,
  ) -> dict[str, Any]:
      """Expand dict key/value selectors into their underlying column names."""
      expanded = {}
      for key, value in (d or {}).items():
          if expand_values and is_selector(value):
              expanded[key] = expand_selector(df, selector=value)
              value = expanded[key]
          if expand_keys and is_selector(key):
              cols = expand_selector(df, selector=key)
              if tuple_keys:
                  expanded[cols] = value
              else:
                  expanded.update({c: value for c in cols})
          else:
              expanded[key] = value
      return expanded
  
imports: from __future__ import annotations
  import re
  from datetime import timezone
  from functools import reduce
  from operator import or_
  from typing import TYPE_CHECKING, Any, Collection, Literal, Mapping, overload
  from polars import functions
  from polars.datatypes import FLOAT_DTYPES, INTEGER_DTYPES, NUMERIC_DTYPES, SIGNED_INTEGER_DTYPES, TEMPORAL_DTYPES, UNSIGNED_INTEGER_DTYPES, Binary, Boolean, Categorical, Date, Datetime, Decimal, Duration, Object, String, Time, is_polars_dtype
  from polars.expr import Expr
  from polars.utils.deprecation import deprecate_nonkeyword_arguments
  from polars.utils.various import is_column
label_desc: Use image node_id 6 for calling a global function with example usage: _expand_selector_dicts(df, d) and returns: expanded