def _split_dataset_by_attribute(
    data: TCLDataset, attr_name: str
) -> Dict[int, TCLDataset]:
    """Helper to split a dataset by attribute.

    :param data: an Avalanche dataset.
    :param attr_name: the name of the attribute of `data` to use for splitting `data`.
    """
    da = getattr(data, attr_name)
    dds = {}
    for el in da.uniques:
        idxs = da.val_to_idx[el]
        dds[el] = data.subset(idxs)
    return dds
Helper to split a dataset by attribute.

    :param data: an Avalanche dataset.
    :param attr_name: the name of the attribute of `data` to use for splitting `data`.
    
avalanche/benchmarks/scenarios/dataset_scenario.py