code: def _refine_defaults_read(
      dialect: str | csv.Dialect | None,
      delimiter: str | None | lib.NoDefault,
      delim_whitespace: bool,
      engine: CSVEngine | None,
      sep: str | None | lib.NoDefault,
      on_bad_lines: str | Callable,
      names: Sequence[Hashable] | None | lib.NoDefault,
      defaults: dict[str, Any],
      dtype_backend: DtypeBackend | lib.NoDefault,
  ):
      """Validate/refine default values of input parameters of read_csv, read_table.
  
      Parameters
      ----------
      dialect : str or csv.Dialect
          If provided, this parameter will override values (default or not) for the
          following parameters: `delimiter`, `doublequote`, `escapechar`,
          `skipinitialspace`, `quotechar`, and `quoting`. If it is necessary to
          override values, a ParserWarning will be issued. See csv.Dialect
          documentation for more details.
      delimiter : str or object
          Alias for sep.
      delim_whitespace : bool
          Specifies whether or not whitespace (e.g. ``' '`` or ``'\t'``) will be
          used as the sep. Equivalent to setting ``sep='\\s+'``. If this option
          is set to True, nothing should be passed in for the ``delimiter``
          parameter.
      engine : {{'c', 'python'}}
          Parser engine to use. The C engine is faster while the python engine is
          currently more feature-complete.
      sep : str or object
          A delimiter provided by the user (str) or a sentinel value, i.e.
          pandas._libs.lib.no_default.
      on_bad_lines : str, callable
          An option for handling bad lines or a sentinel value(None).
      names : array-like, optional
          List of column names to use. If the file contains a header row,
          then you should explicitly pass ``header=0`` to override the column names.
          Duplicates in this list are not allowed.
      defaults: dict
          Default values of input parameters.
  
      Returns
      -------
      kwds : dict
          Input parameters with correct values.
  
      Raises
      ------
      ValueError :
          If a delimiter was specified with ``sep`` (or ``delimiter``) and
          ``delim_whitespace=True``.
      """
      # fix types for sep, delimiter to Union(str, Any)
      delim_default = defaults["delimiter"]
      kwds: dict[str, Any] = {}
      # gh-23761
      #
      # When a dialect is passed, it overrides any of the overlapping
      # parameters passed in directly. We don't want to warn if the
      # default parameters were passed in (since it probably means
      # that the user didn't pass them in explicitly in the first place).
      #
      # "delimiter" is the annoying corner case because we alias it to
      # "sep" before doing comparison to the dialect values later on.
      # Thus, we need a flag to indicate that we need to "override"
      # the comparison to dialect values by checking if default values
      # for BOTH "delimiter" and "sep" were provided.
      if dialect is not None:
          kwds["sep_override"] = delimiter is None and (
              sep is lib.no_default or sep == delim_default
          )
  
      if delimiter and (sep is not lib.no_default):
          raise ValueError(
              "Specified a sep and a delimiter; you can only specify one."
          )
  
      kwds["names"] = None if names is lib.no_default else names
  
      # Alias sep -> delimiter.
      if delimiter is None:
          delimiter = sep
  
      if delim_whitespace and (delimiter is not lib.no_default):
          raise ValueError(
              "Specified a delimiter with both sep and "
              "delim_whitespace=True; you can only specify one."
          )
  
      if delimiter == "\n":
          raise ValueError(
              r"Specified \n as separator or delimiter. This forces the python engine "
              "which does not accept a line terminator. Hence it is not allowed to use "
              "the line terminator as separator.",
          )
  
      if delimiter is lib.no_default:
          # assign default separator value
          kwds["delimiter"] = delim_default
      else:
          kwds["delimiter"] = delimiter
  
      if engine is not None:
          kwds["engine_specified"] = True
      else:
          kwds["engine"] = "c"
          kwds["engine_specified"] = False
  
      if on_bad_lines == "error":
          kwds["on_bad_lines"] = ParserBase.BadLineHandleMethod.ERROR
      elif on_bad_lines == "warn":
          kwds["on_bad_lines"] = ParserBase.BadLineHandleMethod.WARN
      elif on_bad_lines == "skip":
          kwds["on_bad_lines"] = ParserBase.BadLineHandleMethod.SKIP
      elif callable(on_bad_lines):
          if engine != "python":
              raise ValueError(
                  "on_bad_line can only be a callable function if engine='python'"
              )
          kwds["on_bad_lines"] = on_bad_lines
      else:
          raise ValueError(
              f"Argument {on_bad_lines} is invalid for on_bad_lines"
          )
  
      check_dtype_backend(dtype_backend)
  
      kwds["dtype_backend"] = dtype_backend
  
      return kwds
  
imports: from __future__ import annotations
  from collections import abc
  import csv
  import sys
  from textwrap import fill
  from types import TracebackType
  from typing import IO, Any, Callable, Hashable, Literal, NamedTuple, Sequence, overload
  import warnings
  import numpy
  from pandas._libs import lib
  from pandas._libs.parsers import STR_NA_VALUES
  from pandas._typing import CompressionOptions, CSVEngine, DtypeArg, DtypeBackend, FilePath, IndexLabel, ReadCsvBuffer, StorageOptions
  from pandas.errors import AbstractMethodError, ParserWarning
  from pandas.util._decorators import Appender
  from pandas.util._exceptions import find_stack_level
  from pandas.util._validators import check_dtype_backend
  from pandas.core.dtypes.common import is_file_like, is_float, is_integer, is_list_like
  from pandas.core.frame import DataFrame
  from pandas.core.indexes.api import RangeIndex
  from pandas.core.shared_docs import _shared_docs
  from pandas.io.common import IOHandles, get_handle, stringify_path, validate_header_arg
  from pandas.io.parsers.arrow_parser_wrapper import ArrowParserWrapper
  from pandas.io.parsers.base_parser import ParserBase, is_index_col, parser_defaults
  from pandas.io.parsers.c_parser_wrapper import CParserWrapper
  from pandas.io.parsers.python_parser import FixedWidthFieldParser, PythonParser
label_desc: Use image node_id 22 for calling a global function with example usage: _refine_defaults_read(dialect, delimiter, delim_whitespace, engine, sep, on_bad_lines, names, defaults, dtype_backend) and returns: kwds