import itertools


def expand_specs(specs):
    """
    [(X, [X0, X1, ...]), (Y, [Y0, Y1, ...)] ->
      ((X, X0), (Y, Y0)), ((X, X0), (Y, Y1)), ((X, X1), (Y, Y0)), ((X, X1), (Y, Y1))
    """
    all_vals = []

    for name, vals in specs.items():
        all_vals.append([(name, val) for val in vals])

    all_vals = itertools.product(*all_vals)
    return all_vals