def call_function_with_redundant_kwargs(fn, kwargs):
    "Calls a function and returns the results.\n\n    Only those keyword arguments in :attr:`kwargs` that are included in the\n    function's argument list are used to call the function.\n\n    Args:\n        fn (function): A callable. If :attr:`fn` is not a python function,\n            :attr:`fn.__call__` is called.\n        kwargs (dict): A `dict` of arguments for the callable. It\n            may include invalid arguments which will be ignored.\n\n    Returns:\n        The returned results by calling :attr:`fn`.\n    "
    try:
        fn_args = set(get_args(fn))
    except TypeError:
        fn_args = set(get_args(fn.__cal__))
    if (kwargs is None):
        kwargs = {}
    selected_kwargs = {}
    for (key, value) in kwargs.items():
        if (key in fn_args):
            selected_kwargs[key] = value
    return fn(**selected_kwargs)
Calls a function and returns the results.

Only those keyword arguments in :attr:`kwargs` that are included in the
function's argument list are used to call the function.

Args:
    fn (function): A callable. If :attr:`fn` is not a python function,
        :attr:`fn.__call__` is called.
    kwargs (dict): A `dict` of arguments for the callable. It
        may include invalid arguments which will be ignored.

Returns:
    The returned results by calling :attr:`fn`.
def call_function_with_redundant_kwargs(fn, kwargs):
    "Calls a function and returns the results.\n\n    Only those keyword arguments in :attr:`kwargs` that are included in the\n    function's argument list are used to call the function.\n\n    Args:\n        fn (function): A callable. If :attr:`fn` is not a python function,\n            :attr:`fn.__call__` is called.\n        kwargs (dict): A `dict` of arguments for the callable. It\n            may include invalid arguments which will be ignored.\n\n    Returns:\n        The returned results by calling :attr:`fn`.\n    "
    try:
        fn_args = set(get_args(fn))
    except TypeError:
        fn_args = set(get_args(fn.__cal__))
    if (kwargs is None):
        kwargs = {}
    selected_kwargs = {}
    for (key, value) in kwargs.items():
        if (key in fn_args):
            selected_kwargs[key] = value
    return fn(**selected_kwargs)