def create_sub_exp_from_multi_exps(
    original_stream: Iterable[DatasetExperience[TCLDataset]],
    samplers: Iterable[CyclicSampler],
    exp_per_sample_list: Iterable[torch.Tensor],
    total_iters: int,
    is_first_sub_exp: bool = False,
    is_last_sub_exp: bool = False,
) -> DatasetExperience[TCLDataset]:
    """
    Creates a sub-experience from a list of experiences.

    :param original_stream: The original stream.
    :param samplers: A list of samplers, one for each experience in the
            original stream.
    :param exp_per_sample_list: A list of experience ids, one for each sample
            in the sub-experience.
    :param total_iters: The total number of iterations.
    :param is_first_sub_exp: Whether this is the first sub-experience.
    :param is_last_sub_exp: Whether this is the last sub-experience.

    :return: A sub-experience.
    """

    # Create sub-sets from each experience's dataset
    all_subsets = []
    n_samples_from_each_exp = [0 for _ in range(len(samplers))]

    for exp_id in exp_per_sample_list.unique():
        n_samples = sum(exp_per_sample_list == exp_id.item()).item()
        n_samples_from_each_exp[exp_id.item()] += n_samples
        rnd_indices = [next(samplers[exp_id]) for _ in range(n_samples)]
        subset_i = original_stream[exp_id.item()].dataset.subset(rnd_indices)
        all_subsets.append(subset_i)

    # Concatenate all sub-sets
    sub_exp_subset = concat_datasets(all_subsets)

    exp = OnlineCLExperience(
        dataset=sub_exp_subset,
        origin_experience=None,  # experience,
        is_first_subexp=is_first_sub_exp,
        is_last_subexp=is_last_sub_exp,
        sub_stream_length=total_iters,
        access_task_boundaries=False,
    )

    # For visualization purposes only
    exp.n_samples_from_each_exp = n_samples_from_each_exp

    return exp

    Creates a sub-experience from a list of experiences.

    :param original_stream: The original stream.
    :param samplers: A list of samplers, one for each experience in the
            original stream.
    :param exp_per_sample_list: A list of experience ids, one for each sample
            in the sub-experience.
    :param total_iters: The total number of iterations.
    :param is_first_sub_exp: Whether this is the first sub-experience.
    :param is_last_sub_exp: Whether this is the last sub-experience.

    :return: A sub-experience.
    
avalanche/benchmarks/scenarios/online.py