class_docstr: Base class for a downloadable dataset.
  
  It is recommended to extend this class if a dataset can be downloaded from
  the internet. This implementation codes the recommended behaviour for
  downloading and verifying the dataset.
  
  The dataset child class must implement the `_download_dataset`,
  `_load_metadata` and `_download_error_message` methods
  
  The child class, in its constructor, must call the already implemented
  `_load_dataset` method (otherwise nothing will happen).
  
  A further simplification can be obtained by extending
  :class:`SimpleDownloadableDataset` instead of this class.
  :class:`SimpleDownloadableDataset` is recommended if a single archive is to
  be downloaded and extracted to the root folder "as is".
  
  The standardized procedure coded by `_load_dataset` is as follows:
  
  - First, `_load_metadata` is called to check if the dataset can be correctly
    loaded at the `root` path. This method must check if the data found
    at the `root` path is correct and that metadata can be correctly loaded.
    If this method succeeds (by returning True) the process is completed.
  - If `_load_metadata` fails (by returning False or by raising an error),
    then a download will be attempted if the download flag was set to True.
    The download must be implemented in `_download_dataset`. The
    procedure can be drastically simplified by using the `_download_file`,
    `_extract_archive` and `_download_and_extract_archive` helpers.
  - If the download succeeds (doesn't raise an error), then `_load_metadata`
    will be called again.
  
  If an error occurs, the `_download_error_message` will be called to obtain
  a message (a string) to show to the user. That message should contain
  instructions on how to download and prepare the dataset manually.
class_docstr_tok: ["Base","class","for","a","downloadable","dataset",".","It","is","recommended","to","extend","this","class","if","a","dataset","can","be","downloaded","from","the","internet",".","This","implementation","codes","the","recommended","behaviour","for","downloading","and","verifying","the","dataset",".","The","dataset","child","class","must","implement","the","`","_download_dataset","`",",","`","_load_metadata","`","and","`","_download_error_message","`","methods","The","child","class",",","in","its","constructor",",","must","call","the","already","implemented","`","_load_dataset","`","method","(","otherwise","nothing","will","happen",")",".","A","further","simplification","can","be","obtained","by","extending",":","class",":","`","SimpleDownloadableDataset","`","instead","of","this","class",".",":","class",":","`","SimpleDownloadableDataset","`","is","recommended","if","a","single","archive","is","to","be","downloaded","and","extracted","to","the","root","folder","``","as","is","''",".","The","standardized","procedure","coded","by","`","_load_dataset","`","is","as","follows",":","-","First",",","`","_load_metadata","`","is","called","to","check","if","the","dataset","can","be","correctly","loaded","at","the","`","root","`","path",".","This","method","must","check","if","the","data","found","at","the","`","root","`","path","is","correct","and","that","metadata","can","be","correctly","loaded",".","If","this","method","succeeds","(","by","returning","True",")","the","process","is","completed",".","-","If","`","_load_metadata","`","fails","(","by","returning","False","or","by","raising","an","error",")",",","then","a","download","will","be","attempted","if","the","download","flag","was","set","to","True",".","The","download","must","be","implemented","in","`","_download_dataset","`",".","The","procedure","can","be","drastically","simplified","by","using","the","`","_download_file","`",",","`","_extract_archive","`","and","`","_download_and_extract_archive","`","helpers",".","-","If","the","download","succeeds","(","does","n't","raise","an","error",")",",","then","`","_load_metadata","`","will","be","called","again",".","If","an","error","occurs",",","the","`","_download_error_message","`","will","be","called","to","obtain","a","message","(","a","string",")","to","show","to","the","user",".","That","message","should","contain","instructions","on","how","to","download","and","prepare","the","dataset","manually","."]
docstr: The standardized dataset download and load procedure.
  
  For more details on the coded procedure see the class documentation.
  
  This method shouldn't be overridden.
  
  This method will raise and error if the dataset couldn't be loaded
  or downloaded.
  
  :return: None
docstr_tok: ["The","standardized","dataset","download","and","load","procedure",".","For","more","details","on","the","coded","procedure","see","the","class","documentation",".","This","method","should","n't","be","overridden",".","This","method","will","raise","and","error","if","the","dataset","could","n't","be","loaded","or","downloaded",".",":","return",":","None"]
code: def _load_dataset(self) -> None:
      """
      The standardized dataset download and load procedure.
  
      For more details on the coded procedure see the class documentation.
  
      This method shouldn't be overridden.
  
      This method will raise and error if the dataset couldn't be loaded
      or downloaded.
  
      :return: None
      """
      metadata_loaded = False
      metadata_load_error = None
      try:
          metadata_loaded = self._load_metadata()
      except Exception as e:
          metadata_load_error = e
  
      if metadata_loaded:
          if self.verbose:
              print("Files already downloaded and verified")
          return
  
      if not self.download:
          msg = (
              "Error loading dataset metadata (dataset download was "
              'not attempted as "download" is set to False)'
          )
          if metadata_load_error is None:
              raise RuntimeError(msg)
          else:
              print(msg)
              raise metadata_load_error
  
      try:
          self._download_dataset()
      except Exception as e:
          err_msg = self._download_error_message()
          print(err_msg, flush=True)
          raise e
  
      if not self._load_metadata():
          err_msg = self._download_error_message()
          print(err_msg)
          raise RuntimeError(
              "Error loading dataset metadata (... but the download "
              "procedure completed successfully)"
          )
  
imports: from abc import abstractmethod, ABC
  from pathlib import Path
  from typing import TypeVar, Union, Optional
  import shutil
  import os
  from torch.utils.data.dataset import Dataset
  from torchvision.datasets.utils import download_and_extract_archive, extract_archive, download_url, check_integrity
  from avalanche.benchmarks.datasets.dataset_utils import default_dataset_location
label_desc: Use image node_id 2 for calling the DownloadableDataset obj's underlying member method code with example usage: obj._load_dataset() without return types