class_docstr: Endless Continual Leanring Simulator Dataset
class_docstr_tok: ["Endless","Continual","Leanring","Simulator","Dataset"]
docstr: Prepare subsequences.
  
  :param path: (str) Path to the root of the data to be loaded.
  :return: success (bool): Boolean wether the preparation was successfull.
code: def _prepare_classification_subsequence_datasets(self, path) -> bool:
      """Prepare subsequences.
  
      :param path: (str) Path to the root of the data to be loaded.
      :return: success (bool): Boolean wether the preparation was successfull.
      """
      # Get sequence dirs
      sequence_paths = glob.glob(path + os.path.sep + "*" + os.path.sep)
  
      # For every sequence (train, test)
      for sequence_path in sequence_paths:
          sub_sequence_paths = glob.glob(
              sequence_path + os.path.sep + "*" + os.path.sep
          )
          # Get sub-sequence dirs (0,1,....,n)
          for sub_sequence_path in sub_sequence_paths:
              image_paths = []
              targets = []
  
              # Get class dirs
              class_name_dirs = [
                  f.name
                  for f in os.scandir(sub_sequence_path + os.path.sep)
                  if f.is_dir()
              ]
  
              # Load file_paths and targets
              for class_name in class_name_dirs:
                  class_path = (
                      sub_sequence_path + class_name + os.path.sep
                  )
                  for file_name in os.listdir(class_path):
                      image_paths.append(class_path + file_name)
                      targets.append(class_name)
  
              # Create sub-sequence dataset
              subsequence_dataset = ClassificationSubSequence(
                  image_paths,
                  targets,
                  patch_size=self.patch_size,
                  labelmap_path=self.labelmap_path,
                  transform=self.transform,
                  target_transform=self.target_transform,
              )
              if "train" in (sequence_path.lower()):
                  self.train_sub_sequence_datasets.append(
                      subsequence_dataset
                  )
              elif "test" in (sequence_path.lower()):
                  self.test_sub_sequence_datasets.append(
                      subsequence_dataset
                  )
              else:
                  raise ValueError(
                      "Sequence path contains neighter 'train' nor \
                              'test' identifier!"
                  )
  
      # Check number of train and test subsequence datasets are equal
      if self.verbose:
          print(
              "Num train subsequences:",
              len(self.train_sub_sequence_datasets),
              "Num test subsequences:",
              len(self.test_sub_sequence_datasets),
          )
      assert len(self.train_sub_sequence_datasets) == len(
          self.test_sub_sequence_datasets
      )
  
      # Has run without errors
      if self.verbose:
          print("Successfully created subsequence datasets..")
      return True
  
imports: from pathlib import Path
  import glob
  import os
  from typing import List, Optional, Union
  from warnings import warn
  import sys
  import json
  import numpy
  from PIL import Image
  from torch.utils.data import Dataset
  from avalanche.benchmarks.datasets import default_dataset_location
  from avalanche.benchmarks.datasets.endless_cl_sim import endless_cl_sim_data
  from avalanche.benchmarks.datasets.downloadable_dataset import DownloadableDataset
label_desc: Use image node_id 3 for calling the EndlessCLSimDataset obj's underlying member method code with example usage: obj._prepare_classification_subsequence_datasets(path) and returns: True