import random


def random_treatment_order(n_subjects, n_treatments, seed=None):
    """ Create a randomization list for studies where the subject recieves
    multiple treatments.

    If a subject will recieve multiple treatments, those treatments should be
    randomized.

    Args:
        n_subjects: The number of subjects to randomize.
        n_treatments: The number of treatments a subject will
        seed: (optional) The seed to provide to the RNG.

    Returns:
        list: a list of length `n_subjects` of lists of length `n_treatments`.
            Each sublist is treatment order of the subject.
    """

    random.seed(seed)
    treatment = []
    for i in range(0, n_treatments):
        treatment.append(i + 1)
    groups = []
    for i in range(0, n_subjects):
        random.shuffle(treatment)
        groups.append(treatment[:])
    return groups