import itertools


def dict_product(dicts):
    """ Create an iterator from a GridSearchCV-like dictionary

    This code is directly take from stackoverflow:
        http://stackoverflow.com/a/40623158/621449
    """
    return (dict(zip(dicts, x)) for x in itertools.product(*dicts.values()))