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: Utility method to check a file.
  
  :param path: The path to the file.
  :param checksum: The MD5 hash to use.
  :return: True if the MD5 hash of the file matched the given one.
docstr_tok: ["Utility","method","to","check","a","file",".",":","param","path",":","The","path","to","the","file",".",":","param","checksum",":","The","MD5","hash","to","use",".",":","return",":","True","if","the","MD5","hash","of","the","file","matched","the","given","one","."]
code: def _check_file(self, path: Union[str, Path], checksum: str) -> bool:
      """
      Utility method to check a file.
  
      :param path: The path to the file.
      :param checksum: The MD5 hash to use.
      :return: True if the MD5 hash of the file matched the given one.
      """
      return check_integrity(str(path), md5=checksum)
  
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 10 for calling the DownloadableDataset obj's underlying member method code with example usage: obj._check_file(path, checksum) and returns: check_integrity