import itertools


def generate_laplace_prior_data(fields, preprocessor):
    """Create training data for Laplace smoothing

    Generate data needed to apply Laplace smoothing to Bayesian network
    training. The value returned here can be applied to
    `BayesianNetworkModel.train`'s `prior_data` parameter to give each possible
    combination of field values an equal prior.

    Args:
        fields (iterable(string)): the names of all fields in the training data
        preprocessor (Preprocessor): preprocessor used for processing the
            training data, needed because this determines the data's possible
            values.

    Returns: (iterable(value list)) a list of data for use by
        `BayesianNetworkModel.train`'s `prior_data` parameter

    """
    all_values = (preprocessor.get_possible_values(field) for field in fields)
    return set(itertools.product(*all_values))