def new_instances_benchmark(
    train_dataset: ClassificationDataset,
    test_dataset: AvalancheDataset,
    num_experiences: int,
    *,
    shuffle: bool = True,
    seed: Optional[int] = None,
    balance_experiences: bool = False,
    min_class_patterns_in_exp: int = 0,
) -> CLScenario:
    """Benchmark generator for "New Instances" (NI) scenarios.

    Given a `train_dataset` and a `test_dataset, the generator creates a
    benchmark where the training stream is split according to the
    New Instances setting.

    Notice that we don't split the test dataset in this generator because we
    have random splits, so it is more natural to test on the full test set
    at each step instead of an i.i.d. random test split.

    :param train_dataset: An AvalancheDataset used to define the training stream.
    :param test_dataset: A test AvalancheDataset. This will not be split.
    :param num_experiences: The desired stream length.
    :param shuffle: If True, patterns order will be shuffled.
    :param seed: A valid int used to initialize the random number generator.
        Can be None.
    :param balance_experiences: If True, pattern of each class will be equally
        spread across all experiences. If False, patterns will be assigned to
        experiences in a complete random way. Defaults to False.
    :param min_class_patterns_in_exp: The minimum amount of patterns of
        every class that must be assigned to every experience. Compatible with
        the ``balance_experiences`` parameter. An exception will be raised if
        this constraint can't be satisfied. Defaults to 0.

    :return: A properly initialized :class:`NIScenario` instance.
    """

    if balance_experiences:  # class-balanced split
        exps_idxs = _class_balanced_indices(
            data=train_dataset,
            num_experiences=num_experiences,
            shuffle=shuffle,
            seed=seed,
        )
    else:
        exps_idxs = _random_indices(
            data=train_dataset,
            num_experiences=num_experiences,
            shuffle=shuffle,
            seed=seed,
            min_class_patterns_in_exp=min_class_patterns_in_exp,
        )

    train_experiences = []
    for idxs in exps_idxs:
        curr_data = train_dataset.subset(indices=idxs)
        train_experiences.append(DatasetExperience(dataset=curr_data))

    train_stream = CLStream("train", train_experiences)
    test_stream = CLStream("test", [DatasetExperience(dataset=test_dataset)])
    return CLScenario(streams=[train_stream, test_stream])
Benchmark generator for "New Instances" (NI) scenarios.

    Given a `train_dataset` and a `test_dataset, the generator creates a
    benchmark where the training stream is split according to the
    New Instances setting.

    Notice that we don't split the test dataset in this generator because we
    have random splits, so it is more natural to test on the full test set
    at each step instead of an i.i.d. random test split.

    :param train_dataset: An AvalancheDataset used to define the training stream.
    :param test_dataset: A test AvalancheDataset. This will not be split.
    :param num_experiences: The desired stream length.
    :param shuffle: If True, patterns order will be shuffled.
    :param seed: A valid int used to initialize the random number generator.
        Can be None.
    :param balance_experiences: If True, pattern of each class will be equally
        spread across all experiences. If False, patterns will be assigned to
        experiences in a complete random way. Defaults to False.
    :param min_class_patterns_in_exp: The minimum amount of patterns of
        every class that must be assigned to every experience. Compatible with
        the ``balance_experiences`` parameter. An exception will be raised if
        this constraint can't be satisfied. Defaults to 0.

    :return: A properly initialized :class:`NIScenario` instance.
    
avalanche/benchmarks/scenarios/supervised.py