r"""
    Args:
        dict1 (dict):
        dict2 (dict):
        combine (bool): Combines keys only if the values are equal if False else
            values are combined using combine_op (default = False)
        combine_op (func): (default = op.add)

    Returns:
        dict: mergedict_

    CommandLine:
        python -m utool.util_dict --exec-dict_intersection

    Example:
        >>> # ENABLE_DOCTEST
        >>> from utool.util_dict import *  # NOQA
        >>> import utool as ut
        >>> dict1 = {'a': 1, 'b': 2, 'c': 3, 'd': 4}
        >>> dict2 = {'b': 2, 'c': 3, 'd': 5, 'e': 21, 'f': 42}
        >>> combine = False
        >>> mergedict_ = dict_intersection(dict1, dict2, combine)
        >>> result = ('mergedict_ = %s' % (ut.repr4(mergedict_, nl=False),))
        >>> print(result)
        mergedict_ = {'b': 2, 'c': 3}

def dict_intersection(dict1, dict2, combine=False, combine_op=op.add):
    r"""
    Args:
        dict1 (dict):
        dict2 (dict):
        combine (bool): Combines keys only if the values are equal if False else
            values are combined using combine_op (default = False)
        combine_op (func): (default = op.add)

    Returns:
        dict: mergedict_

    CommandLine:
        python -m utool.util_dict --exec-dict_intersection

    Example:
        >>> # ENABLE_DOCTEST
        >>> from utool.util_dict import *  # NOQA
        >>> import utool as ut
        >>> dict1 = {'a': 1, 'b': 2, 'c': 3, 'd': 4}
        >>> dict2 = {'b': 2, 'c': 3, 'd': 5, 'e': 21, 'f': 42}
        >>> combine = False
        >>> mergedict_ = dict_intersection(dict1, dict2, combine)
        >>> result = ('mergedict_ = %s' % (ut.repr4(mergedict_, nl=False),))
        >>> print(result)
        mergedict_ = {'b': 2, 'c': 3}
    """
    isect_keys = set(dict1.keys()).intersection(set(dict2.keys()))
    if combine:
        # TODO: depricate this
        dict_isect = {k: combine_op(dict1[k], dict2[k]) for k in isect_keys}
    else:
        # maintain order if possible
        if isinstance(dict1, OrderedDict):
            isect_keys_ = [k for k in dict1.keys() if k in isect_keys]
            _dict_cls = OrderedDict
        else:
            isect_keys_ = isect_keys
            _dict_cls = dict
        dict_isect = _dict_cls(
            (k, dict1[k]) for k in isect_keys_ if dict1[k] == dict2[k]
        )
    return dict_isect