code: def _unpack_schema(
      schema: SchemaDefinition | None,
      *,
      schema_overrides: SchemaDict | None = None,
      n_expected: int | None = None,
      lookup_names: Iterable[str] | None = None,
      include_overrides_in_columns: bool = False,
  ) -> tuple[list[str], SchemaDict]:
      """
      Unpack column names and create dtype lookup.
  
      Works for any (name, dtype) pairs or schema dict input,
      overriding any inferred dtypes with explicit dtypes if supplied.
      """
      # coerce schema_overrides to dict[str, PolarsDataType]
      if schema_overrides:
          schema_overrides = {
              name: dtype
              if is_polars_dtype(dtype, include_unknown=True)
              else py_type_to_dtype(dtype)
              for name, dtype in schema_overrides.items()
          }
      else:
          schema_overrides = {}
  
      # fastpath for empty schema
      if not schema:
          return (
              [f"column_{i}" for i in range(n_expected)]
              if n_expected
              else [],
              schema_overrides,
          )
  
      # determine column names from schema
      if isinstance(schema, Mapping):
          column_names: list[str] = list(schema)
          # coerce schema to list[str | tuple[str, PolarsDataType | PythonDataType | None]
          schema = list(schema.items())
      else:
          column_names = [
              (col or f"column_{i}") if isinstance(col, str) else col[0]
              for i, col in enumerate(schema)
          ]
  
      # determine column dtypes from schema and lookup_names
      lookup: dict[str, str] | None = (
          {
              col: name
              for col, name in zip_longest(column_names, lookup_names)
              if name
          }
          if lookup_names
          else None
      )
      column_dtypes: dict[str, PolarsDataType] = {
          lookup.get((name := col[0]), name)
          if lookup
          else col[0]: dtype  # type: ignore[misc]
          if is_polars_dtype(dtype, include_unknown=True)
          else py_type_to_dtype(dtype)
          for col in schema
          if isinstance(col, tuple) and (dtype := col[1]) is not None
      }
  
      # apply schema overrides
      if schema_overrides:
          column_dtypes.update(schema_overrides)
  
          if include_overrides_in_columns:
              column_names.extend(
                  col
                  for col in column_dtypes
                  if col not in column_names
              )
  
      return column_names, column_dtypes
  
imports: from __future__ import annotations
  import contextlib
  import warnings
  from datetime import date, datetime, time, timedelta
  from decimal import Decimal
  from functools import lru_cache, singledispatch
  from itertools import islice, zip_longest
  from operator import itemgetter
  from sys import version_info
  from typing import TYPE_CHECKING, Any, Callable, Generator, Iterable, Iterator, Mapping, MutableMapping, Sequence, get_type_hints
  import polars._reexport
  from polars import functions
  from polars.datatypes import INTEGER_DTYPES, N_INFER_DEFAULT, TEMPORAL_DTYPES, Boolean, Categorical, Date, Datetime, Duration, Enum, List, Null, Object, String, Struct, Time, UInt32, Unknown, dtype_to_py_type, is_polars_dtype, numpy_char_code_to_dtype, py_type_to_dtype
  from polars.datatypes.constructor import numpy_type_to_constructor, numpy_values_and_dtype, polars_type_to_constructor, py_type_to_constructor
  from polars.dependencies import _NUMPY_AVAILABLE, _check_for_numpy, _check_for_pandas, _check_for_pydantic, dataclasses, pydantic
  from polars.dependencies import numpy
  from polars.dependencies import pandas
  from polars.dependencies import pyarrow
  from polars.exceptions import ComputeError, ShapeError, TimeZoneAwareConstructorWarning
  from polars.utils._wrap import wrap_df, wrap_s
  from polars.utils.meta import get_index_type, threadpool_size
  from polars.utils.various import _is_generator, arrlen, find_stacklevel, parse_version, range_to_series
label_desc: Use image node_id 20 for calling a global function with example usage: _unpack_schema(schema) and returns: column_names,  column_dtypes, unknown,  schema_overrides