import itertools
import functools


def dict_combinations(*dict_list_lists):
    """Given a list of lists of dictionaries return the list of
    all possible dictionaries resulting from the unions of sampling
    a dictionary from each list.

    Basically given a list of lists of dictionaries, returns all the
    dictionaries that are a ersult of sampling items from each of the lists
    """
    combinations = itertools.product(*dict_list_lists)  # cartesian product of all the lists
    return map(lambda comb: functools.reduce(lambda a, b: dict(list(a.items()) + list(b.items())),
                                             comb, {}), combinations)