code: def _filter_kwargs(function: Callable, **kwargs: Any) -> Any:
      r"""Filter out kwargs that are not applicable for a given function.
      Return a copy of given kwargs dict with only the required kwargs.
      """
      allowed_params = signature(function).parameters
      removed = {k for k in kwargs.keys() if k not in allowed_params}
      if len(removed) > 0:
          fn_descriptor = (
              f" for function {function.__name__}"
              if hasattr(function, "__name__")
              else ""
          )
          warn(
              f"Keyword arguments {list(removed)} will be ignored because they are"
              f" not allowed parameters{fn_descriptor}. Allowed "
              f"parameters are {list(allowed_params.keys())}."
          )
      return {k: v for k, v in kwargs.items() if k not in removed}
  
file_path: botorch/botorch/optim/utils/common.py
imports: from __future__ import annotations
  from inspect import signature
  from logging import debug
  from typing import Any, Callable, Optional, Tuple
  from warnings import warn, warn_explicit, WarningMessage
  import numpy
  from linear_operator.utils.errors import NanError, NotPSDError
label_desc: Use image node_id 1 for calling a global function with example usage: _filter_kwargs(function) and returns: unknown