:return:
        a pair producer that enables dynamic callback query origin mapping
        across seeder and delegator.

    :param origins:
        ``all`` or a list of origin types (``chat``, ``inline``).
        Origin mapping is only enabled for specified origin types.

def intercept_callback_query_origin(fn=pair, origins='all'):
    """
    :return:
        a pair producer that enables dynamic callback query origin mapping
        across seeder and delegator.

    :param origins:
        ``all`` or a list of origin types (``chat``, ``inline``).
        Origin mapping is only enabled for specified origin types.
    """
    origin_map = helper.SafeDict()

    # For key functions that returns a tuple as key (e.g. per_callback_query_origin()),
    # wrap the key in another tuple to prevent router from mistaking it as
    # a key followed by some arguments.
    def tuplize(fn):
        def tp(msg):
            return (fn(msg),)
        return tp

    router = helper.Router(tuplize(per_callback_query_origin(origins=origins)),
                           origin_map)

    def modify_origin_map(origin, dest, set):
        if set:
            origin_map[origin] = dest
        else:
            try:
                del origin_map[origin]
            except KeyError:
                pass

    if origins == 'all':
        intercept = modify_origin_map
    else:
        intercept = (modify_origin_map if 'chat' in origins else False,
                     modify_origin_map if 'inline' in origins else False)

    @_ensure_seeders_list
    def p(seeders, delegator_factory, *args, **kwargs):
        return fn(seeders + [_wrap_none(router.map)],
                  delegator_factory, *args, intercept_callback_query=intercept, **kwargs)
    return p