def get_instance_with_redundant_kwargs(class_name, kwargs, module_paths=None):
    'Creates a class instance.\n\n    Only those keyword arguments in :attr:`kwargs` that are included in the\n    class construction method are used.\n\n    Args:\n        class_name (str): A class or its name or module path.\n        kwargs (dict): A dictionary of arguments for the class constructor. It\n            may include invalid arguments which will be ignored.\n        module_paths (list of str): A list of paths to candidate modules to\n            search for the class. This is used if the class cannot be located\n            solely based on :attr:`class_name`. The first module in the list\n            that contains the class is used.\n\n    Returns:\n        A class instance.\n\n    Raises:\n        ValueError: If class is not found based on :attr:`class_name` and\n            :attr:`module_paths`.\n    '
    class_ = get_class(class_name, module_paths)
    selected_kwargs = {}
    class_args = set(get_args(class_.__init__))
    if (kwargs is None):
        kwargs = {}
    for (key, value) in kwargs.items():
        if (key in class_args):
            selected_kwargs[key] = value
    return class_(**selected_kwargs)
Creates a class instance.

Only those keyword arguments in :attr:`kwargs` that are included in the
class construction method are used.

Args:
    class_name (str): A class or its name or module path.
    kwargs (dict): A dictionary of arguments for the class constructor. It
        may include invalid arguments which will be ignored.
    module_paths (list of str): A list of paths to candidate modules to
        search for the class. This is used if the class cannot be located
        solely based on :attr:`class_name`. The first module in the list
        that contains the class is used.

Returns:
    A class instance.

Raises:
    ValueError: If class is not found based on :attr:`class_name` and
        :attr:`module_paths`.
def get_instance_with_redundant_kwargs(class_name, kwargs, module_paths=None):
    'Creates a class instance.\n\n    Only those keyword arguments in :attr:`kwargs` that are included in the\n    class construction method are used.\n\n    Args:\n        class_name (str): A class or its name or module path.\n        kwargs (dict): A dictionary of arguments for the class constructor. It\n            may include invalid arguments which will be ignored.\n        module_paths (list of str): A list of paths to candidate modules to\n            search for the class. This is used if the class cannot be located\n            solely based on :attr:`class_name`. The first module in the list\n            that contains the class is used.\n\n    Returns:\n        A class instance.\n\n    Raises:\n        ValueError: If class is not found based on :attr:`class_name` and\n            :attr:`module_paths`.\n    '
    class_ = get_class(class_name, module_paths)
    selected_kwargs = {}
    class_args = set(get_args(class_.__init__))
    if (kwargs is None):
        kwargs = {}
    for (key, value) in kwargs.items():
        if (key in class_args):
            selected_kwargs[key] = value
    return class_(**selected_kwargs)