class_docstr: A lazily initialized sequence of datasets.
  
  This class provides a way to lazily generate and store the datasets
  linked to each experience. This class uses a generator to get the sequence
  of datasets but it can also be used with a more classic statically
  initialized Sequence (like a list).
  
  This class will also keep track of the targets and task labels field of the
  generated datasets.
code: def __init__(
      self,
      experience_generator: Iterable[TCLDataset],
      stream_length: int,
  ):
      self._exp_source: Optional[
          Iterable[TCLDataset]
      ] = experience_generator
      """
          The source of the experiences stream, as an Iterable.
          
          Can be a simple Sequence or a Generator.
          
          This field is kept for reference and debugging. The actual generator
          is kept in the `_exp_generator` field, which stores the iterator.
          
          This field is None when if all the experiences have been loaded.
          """
  
      self._next_exp_id: int = 0
      """
          The ID of the next experience that will be generated.
          """
  
      self._loaded_experiences: Dict[int, TCLDataset] = dict()
      """
          The sequence of experiences obtained from the generator.
          """
  
      self._stream_length: int = stream_length
      """
          The length of the stream.
          """
      try:
          self._exp_generator: Optional[Iterator[TCLDataset]] = iter(
              self._exp_source
          )
      except TypeError as e:
          if callable(self._exp_source):
              # https://stackoverflow.com/a/17092033
              raise ValueError(
                  "The provided generator is not iterable. When using a "
                  'generator function based on "yield", remember to pass the'
                  " result of that function, not the "
                  "function itself!"
              ) from None
          raise e
      """
          The experience generator, as an Iterator.
          
          This field is None when if all the experiences have been loaded.
          """
  
      self.targets_field_sequence: Dict[
          int, Optional[Sequence]
      ] = defaultdict(lambda: None)
      """
          A dictionary mapping each experience to its `targets` field.
          
          This dictionary contains the targets field of datasets generated up to
          now, including the ones of dropped experiences.
          """
  
      self.task_labels_field_sequence: Dict[
          int, Optional[Sequence[int]]
      ] = defaultdict(lambda: None)
      """
          A dictionary mapping each experience to its `targets_task_labels` field.
  
          This dictionary contains the task labels of datasets generated up to
          now, including the ones of dropped experiences.
          """
  
file_path: avalanche/avalanche/benchmarks/scenarios/deprecated/lazy_dataset_sequence.py
imports: from collections import defaultdict
  from typing import Callable, Sequence, Iterable, Dict, Optional, Iterator, TypeVar, Union
  from typing_extensions import overload
  from avalanche.benchmarks.utils.data import AvalancheDataset
  from avalanche.benchmarks.utils.dataset_utils import manage_advanced_indexing
label_desc: Use image node_id 1 to create a new LazyDatasetSequence object from inherited base classes: Sequence with example: obj = LazyDatasetSequence(experience_generator, stream_length)