def __init__(
        self,
        datasets: Sequence[IDataset[T_co]],
        indices: Optional[List[int]] = None,
        can_flatten: bool = True,
        discard_elements_not_in_indices: bool = False,
    ):
        """Constructor

        :param datasets: list of datasets to concatenate.
        :param indices:  list of indices.
        :param can_flatten: if True, enables flattening.
        :param discard_elements_not_in_indices: if True, will remove
            (drop the reference to) elements not in indices.
            Works only if all datasets are lists. If False (default),
            will use the standard subsetting approach of keeping
            the references to the original datasets.
            Setting this to True is useful when in need to keep
            raw data in memory (such as intermediate activations).
            For an example, please check how this is used
            in the :class:`ClassBalancedBufferWithLogits` of the
            :class:`DER` strategy.
        """
        self._datasets: List[IDataset[T_co]] = list(datasets)
        self._indices: Optional[List[int]] = indices
        self._can_flatten: bool = can_flatten
        self._discard_elements_not_in_indices: bool = discard_elements_not_in_indices

        if can_flatten:
            self._datasets = _flatten_dataset_list(self._datasets)
            self._datasets, self._indices = _flatten_datasets_and_reindex(
                self._datasets, self._indices
            )
        self._cumulative_sizes = ConcatDataset.cumsum(self._datasets)

        if discard_elements_not_in_indices:
            self._remove_unused_elements()

        # NOTE: check disabled to avoid slowing down OCL scenarios
        # # check indices
        # if self._indices is not None and len(self) > 0:
        #     assert min(self._indices) >= 0
        #     assert max(self._indices) < self._cumulative_sizes[-1], \
        #         f"Max index {max(self._indices)} is greater than datasets " \
        #         f"list size {self._cumulative_sizes[-1]}"
Constructor

        :param datasets: list of datasets to concatenate.
        :param indices:  list of indices.
        :param can_flatten: if True, enables flattening.
        :param discard_elements_not_in_indices: if True, will remove
            (drop the reference to) elements not in indices.
            Works only if all datasets are lists. If False (default),
            will use the standard subsetting approach of keeping
            the references to the original datasets.
            Setting this to True is useful when in need to keep
            raw data in memory (such as intermediate activations).
            For an example, please check how this is used
            in the :class:`ClassBalancedBufferWithLogits` of the
            :class:`DER` strategy.
        
avalanche/benchmarks/utils/flat_data.py