def pare_dict(d, ref, strict_b=False, **kw):
    """Pare down a dict D according to a reference dict REF.

    Returns a dict, a pared-down version of D. Any item in D that matches
            an item in REF is removed from the output dict.

    Arguments:
        D:          the dict to be pared down
        REF:        a reference dict to be used for paring
        STRICT_B:   determines the paring mode.
                    If False, the output is as described above.
                    If True, all keys in D not in REF are also removed.
    """
    strict_b = kw.get("strict", strict_b)
    if strict_b:
        return {k: v for k, v in d.items() if k in ref and v != ref.get(k)}
    return {k: v for k, v in d.items() if k not in ref or v != ref.get(k)}