def mk_inclusion_filter(include=(), key=None):
    """
    Creates a function to perform inclusion filtering (i.e. "filter-in if x is in include list")
    :param include: a list-like of elements for an inclusion filter
    :param key: None (default), a callable, or a hashable. If
        * None, the filter will be determined by: x in include
        * callable, the filter will be determined by: key(x) in include
        * hashable, the filter will be determined by: x[key] in include
    :return: a filter function (a function that returns True or False)
    >>> filt = mk_inclusion_filter(include=[2, 4])
    >>> filter(filt, [1, 2, 3, 4, 2, 3, 4, 3, 4])
    [2, 4, 2, 4, 4]
    >>> filt = mk_inclusion_filter(include=[2, 4], key='val')
    >>> filter(filt, [{'name': 'four', 'val': 4}, {'name': 'three', 'val': 3}, {'name': 'two', 'val': 2}])
    [{'name': 'four', 'val': 4}, {'name': 'two', 'val': 2}]
    >>> filt = mk_inclusion_filter(include=[2, 4], key=2)
    >>> filter(filt, [(1, 2, 3), (1, 2, 4), (2, 7, 4), (1, 2, 7)])
    [(1, 2, 4), (2, 7, 4)]
    >>> filt = mk_inclusion_filter(include=[2, 4], key=lambda x: x[0] * x[1])
    >>> filter(filt, [(1, 2, 'is 2'), (2, 2, 'is 4'), (2, 3, 'is 6'), (1, 4, 'is 4')])
    [(1, 2, 'is 2'), (2, 2, 'is 4'), (1, 4, 'is 4')]
    """
    include = set(include)

    if key is None:
        def filter_func(x):
            return x in include
    else:
        if callable(key):
            def filter_func(x):
                return key(x) in include
        else:
            def filter_func(x):
                return x[key] in include

    return filter_func