import inspect


def partition_keywords(f, kw):
    """Partitions keywords into compatible and incompatible with f.

    Return:
        good: key/value pairs that the function f recognizes.
        bad: key/value pairs that the function f does not recognize.

    """
    spec = inspect.getfullargspec(f)
    if spec.varkw:
        return kw, {}
    valid = spec.args + spec.kwonlyargs

    good = {k: v for k, v in kw.items() if k in valid}
    bad = {k: v for k, v in kw.items() if k not in valid}

    return good, bad