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.
docstr: Load all experiences up to a certain experience ID (inclusive).
  
  Beware that this won't re-load any already dropped experience.
  
  :param to_exp: The ID of the last exp to load (inclusive). If None,
      the whole stream will be loaded.
  :return: None
docstr_tok: ["Load","all","experiences","up","to","a","certain","experience","ID","(","inclusive",")",".","Beware","that","this","wo","n't","re-load","any","already","dropped","experience",".",":","param","to_exp",":","The","ID","of","the","last","exp","to","load","(","inclusive",")",".","If","None",",","the","whole","stream","will","be","loaded",".",":","return",":","None"]
code: def load_all_experiences(self, to_exp: Optional[int] = None) -> None:
      """
      Load all experiences up to a certain experience ID (inclusive).
  
      Beware that this won't re-load any already dropped experience.
  
      :param to_exp: The ID of the last exp to load (inclusive). If None,
          the whole stream will be loaded.
      :return: None
      """
      if to_exp is None:
          to_exp = len(self) - 1
      else:
          to_exp = int(to_exp)  # Handle single element tensors
  
      if to_exp >= len(self):
          raise IndexError(
              f"The stream doesn't contain {to_exp+1}" f"experiences"
          )
  
      if self._next_exp_id > to_exp:
          # Nothing to do
          return
  
      exp_gen = self._exp_generator
      assert exp_gen is not None
  
      for exp_id in range(self._next_exp_id, to_exp + 1):
          try:
              generated_exp: TCLDataset = next(exp_gen)
          except StopIteration:
              raise RuntimeError(
                  f"Unexpected end of stream. The generator was supposed to "
                  f"generate {len(self)} experiences, but an error occurred "
                  f"while generating experience {exp_id}."
              )
  
          if not isinstance(generated_exp, AvalancheDataset):
              raise ValueError(
                  "All experience datasets must be subclasses of"
                  " AvalancheDataset"
              )
  
          self._loaded_experiences[exp_id] = generated_exp
          self.targets_field_sequence[exp_id] = list(
              getattr(generated_exp, "targets")
          )
          self.task_labels_field_sequence[exp_id] = list(
              getattr(generated_exp, "targets_task_labels")
          )
          self._next_exp_id += 1
  
      if self._next_exp_id >= len(self):
          # Release all references to the generator
          self._exp_generator = None
          self._exp_source = None
  
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 9 for calling the LazyDatasetSequence obj's underlying member method code with example usage: obj.load_all_experiences(to_exp) without return types