from typing import Callable
from typing import Mapping
from typing import Any
import inspect


def _invoke(f: Callable, kwargs: Mapping[str, Any]) -> Any:
    """
    Invoke the given function with a given dictionary of keyword arguments, silently ignoring any extra arguments.
    """
    signature = inspect.signature(f)
    kwargs = {name: kwargs.get(name, param.default) for name, param in signature.parameters.items()}
    return f(**kwargs)