import itertools


def gen_architectures(lengths, values, decreasing_only=True):
    """
    Generates a list of architecture given the number of layer and each different number of neurones per layer.
    :param lengths: Number of layer (list of int).
    :param values: Neurones per layer (list of int).
    :param decreasing_only: If True, each layer positioned after another one will have less or the same amout of
        neurones. If false, every combinations will be returned.
    :return: A list of architectures, to fill in the "architecture" argument of tune_params.
    """
    ret = []
    if decreasing_only:
        for length in lengths:
            ret.extend(sorted(list(itertools.combinations_with_replacement(sorted(values, reverse=True), length))))
    else:
        for length in lengths:
            ret.extend(sorted(list(itertools.product(sorted(values, reverse=True), repeat=length))))
    return ret