def task_incremental_benchmark(bm: CLScenario, reset_task_labels=False) -> CLScenario:
    """Creates a task-incremental benchmark from a dataset scenario.

    Adds progressive task labels to each stream (experience $i$ has task label $i$).
    Task labels are also added to each `AvalancheDataset` and will be returned by the `__getitem__`.
    For example, if your datasets have `<x, y>` samples (input, class),
    the new datasets will return `<x, y, t>` triplets, where `t` is the task label.

    Example of usage - SplitMNIST with task labels::

        bm = SplitMNIST(2)  # create class-incremental splits
        bm = task_incremental_benchmark(bm)  # adds task labels to the benchmark

    If `reset_task_labels is False` (default) the datasets *must not have task labels
    already set*. If the dataset have task labels, use::

        with_task_labels(benchmark_from_datasets(**dataset_streams)

    :param **dataset_streams: keys are stream names, values are list of datasets.
    :param reset_task_labels: whether existing task labels should be ignored.
        If False (default) if any dataset has task labels the function will raise
        a ValueError. If `True`, it will reset task labels.

    :return: a CLScenario in the task-incremental setting.
    """
    # TODO: when/how to do label_remapping?

    streams = []
    for name, stream in bm.streams.items():
        new_stream = []
        for eid, exp in enumerate(stream):
            if has_task_labels(exp.dataset) and (not reset_task_labels):
                raise ValueError(
                    "AvalancheDataset already has task labels. Use `benchmark_from_datasets` "
                    "instead or set `reset_task_labels=True`."
                )
            tls = TaskLabels(ConstantSequence(eid, len(exp.dataset)))
            new_dd = exp.dataset.update_data_attribute(
                name="targets_task_labels", new_value=tls
            )
            new_exp = DatasetExperience(dataset=new_dd, current_experience=eid)
            new_stream.append(new_exp)
        s = EagerCLStream(name, new_stream)
        streams.append(s)
    return with_task_labels(CLScenario(streams))
Creates a task-incremental benchmark from a dataset scenario.

    Adds progressive task labels to each stream (experience $i$ has task label $i$).
    Task labels are also added to each `AvalancheDataset` and will be returned by the `__getitem__`.
    For example, if your datasets have `<x, y>` samples (input, class),
    the new datasets will return `<x, y, t>` triplets, where `t` is the task label.

    Example of usage - SplitMNIST with task labels::

        bm = SplitMNIST(2)  # create class-incremental splits
        bm = task_incremental_benchmark(bm)  # adds task labels to the benchmark

    If `reset_task_labels is False` (default) the datasets *must not have task labels
    already set*. If the dataset have task labels, use::

        with_task_labels(benchmark_from_datasets(**dataset_streams)

    :param **dataset_streams: keys are stream names, values are list of datasets.
    :param reset_task_labels: whether existing task labels should be ignored.
        If False (default) if any dataset has task labels the function will raise
        a ValueError. If `True`, it will reset task labels.

    :return: a CLScenario in the task-incremental setting.
    
avalanche/benchmarks/scenarios/task_aware.py