-----
    Brief
    -----
    Function for filtering kwargs, ensuring that invalid keywords are not passed as arguments.

    -----------
    Description
    -----------
    Many Python functions included in the major packages, include in their definition some
    keyword arguments (kwargs), i.e., a dictionary having as keys non-formal parameters.

    In spite of not being formally defined, only certain keywords are accepted.

    In order to avoid that the biosignalsnotebooks user gets some errors due to an invalid keyword
    argument, when invoking functions such as 'plot' ('visualise' module), _filter_keywords receives
    the keywords entered by the user, checks if these keywords are valid and only returns a
    dictionary with the valid ones.

    ----------
    Parameters
    ----------
    function : function name
        Function where the **kwargs dictionary must be applied.

    kwargs_dict : dict
        Variable keyword arguments.

    is_class : bool
        Flag to specify if the function input is in fact a Class.

    warn_print : bool
        Flag to specify if a warning should be printed in case a key argunment is invalid.

    Returns
    -------
    kwargs_final : dict
        A filtered dictionary of valid kwargs for using in the specified function.

def _filter_keywords(function, kwargs_dict, is_class=False, warn_print=True):
    """
    -----
    Brief
    -----
    Function for filtering kwargs, ensuring that invalid keywords are not passed as arguments.

    -----------
    Description
    -----------
    Many Python functions included in the major packages, include in their definition some
    keyword arguments (kwargs), i.e., a dictionary having as keys non-formal parameters.

    In spite of not being formally defined, only certain keywords are accepted.

    In order to avoid that the biosignalsnotebooks user gets some errors due to an invalid keyword
    argument, when invoking functions such as 'plot' ('visualise' module), _filter_keywords receives
    the keywords entered by the user, checks if these keywords are valid and only returns a
    dictionary with the valid ones.

    ----------
    Parameters
    ----------
    function : function name
        Function where the **kwargs dictionary must be applied.

    kwargs_dict : dict
        Variable keyword arguments.

    is_class : bool
        Flag to specify if the function input is in fact a Class.

    warn_print : bool
        Flag to specify if a warning should be printed in case a key argunment is invalid.

    Returns
    -------
    kwargs_final : dict
        A filtered dictionary of valid kwargs for using in the specified function.
    """

    # %%%%%%%%%%%%%%%%%%%%%%%%%% List of keywords of our input function %%%%%%%%%%%%%%%%%%%%%%%%%%%
    if is_class is False:
        list_of_keywords = list(signature(function).parameters.keys())
    else:
        list_of_keywords = list(function.__dict__.keys())

    # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    # %% List of keywords passed in **kwargs that match the valid keywords of the input function %%
    # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    available_keywords = set(kwargs_dict.keys())
    valid_keywords = list(available_keywords.intersection(list_of_keywords))

    # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Final kwargs %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    bool_val, inv_keys = _inv_key(list(available_keywords), list_of_keywords)
    if not bool_val:
        str_inval_keys = ""
        for inval_key in inv_keys:
            str_inval_keys += " " + str(inval_key) + ";"
            if warn_print is True:
                warn(RuntimeWarning("At least one of the specified kwargs is not applied "
                                    "in numpy.loadtxt function" + str_inval_keys),
                     stacklevel=2)
                break

    kwargs_final = dict((your_key, kwargs_dict[your_key]) for your_key in valid_keywords)

    return kwargs_final