def getValidKeywords(kw, func):
    """ This function returns a dictionary containing the keywords arguments in initial_kw
        that are valid for function func.
    """
    import inspect
    valid_kw = {}
    invalid_kw = kw.copy()
    args = inspect.getfullargspec(func)
    for k, v in kw.items():
        if k in args.args:
            valid_kw[k] = v
            del invalid_kw[k]
    return valid_kw, invalid_kw
