class_docstr: *Speech Commands* :cite:`speechcommandsv2` dataset.
  
  Args:
      root (str or Path): Path to the directory where the dataset is found or downloaded.
      url (str, optional): The URL to download the dataset from,
          or the type of the dataset to dowload.
          Allowed type values are ``"speech_commands_v0.01"`` and ``"speech_commands_v0.02"``
          (default: ``"speech_commands_v0.02"``)
      folder_in_archive (str, optional):
          The top-level directory of the dataset. (default: ``"SpeechCommands"``)
      download (bool, optional):
          Whether to download the dataset if it is not found at root path. (default: ``False``).
      subset (str or None, optional):
          Select a subset of the dataset [None, "training", "validation", "testing"]. None means
          the whole dataset. "validation" and "testing" are defined in "validation_list.txt" and
          "testing_list.txt", respectively, and "training" is the rest. Details for the files
          "validation_list.txt" and "testing_list.txt" are explained in the README of the dataset
          and in the introduction of Section 7 of the original paper and its reference 12. The
          original paper can be found `here <https://arxiv.org/pdf/1804.03209.pdf>`_. (Default: ``None``)
class_docstr_tok: ["*","Speech","Commands","*",":","cite",":","`","speechcommandsv2","`","dataset",".","Args",":","root","(","str","or","Path",")",":","Path","to","the","directory","where","the","dataset","is","found","or","downloaded",".","url","(","str",",","optional",")",":","The","URL","to","download","the","dataset","from",",","or","the","type","of","the","dataset","to","dowload",".","Allowed","type","values","are","``","``","speech_commands_v0.01","''","``","and","``","``","speech_commands_v0.02","''","``","(","default",":","``","``","speech_commands_v0.02","''","``",")","folder_in_archive","(","str",",","optional",")",":","The","top-level","directory","of","the","dataset",".","(","default",":","``","``","SpeechCommands","''","``",")","download","(","bool",",","optional",")",":","Whether","to","download","the","dataset","if","it","is","not","found","at","root","path",".","(","default",":","``","False","``",")",".","subset","(","str","or","None",",","optional",")",":","Select","a","subset","of","the","dataset","[","None",",","``","training","''",",","``","validation","''",",","``","testing","''","]",".","None","means","the","whole","dataset",".","``","validation","''","and","``","testing","''","are","defined","in","``","validation_list.txt","''","and","``","testing_list.txt","''",",","respectively",",","and","``","training","''","is","the","rest",".","Details","for","the","files","``","validation_list.txt","''","and","``","testing_list.txt","''","are","explained","in","the","README","of","the","dataset","and","in","the","introduction","of","Section","7","of","the","original","paper","and","its","reference","12",".","The","original","paper","can","be","found","`","here","<","https",":","\/\/arxiv.org\/pdf\/1804.03209.pdf",">","`","_",".","(","Default",":","``","None","``",")"]
code: def __init__(
      self,
      root: Union[str, Path],
      url: str = URL,
      folder_in_archive: str = FOLDER_IN_ARCHIVE,
      download: bool = False,
      subset: Optional[str] = None,
  ) -> None:
      if subset is not None and subset not in [
          "training",
          "validation",
          "testing",
      ]:
          raise ValueError(
              "When `subset` is not None, it must be one of ['training', 'validation', 'testing']."
          )
  
      if url in [
          "speech_commands_v0.01",
          "speech_commands_v0.02",
      ]:
          base_url = "http://download.tensorflow.org/data/"
          ext_archive = ".tar.gz"
  
          url = os.path.join(base_url, url + ext_archive)
  
      # Get string representation of 'root' in case Path object is passed
      root = os.fspath(root)
      self._archive = os.path.join(root, folder_in_archive)
  
      basename = os.path.basename(url)
      archive = os.path.join(root, basename)
  
      basename = basename.rsplit(".", 2)[0]
      folder_in_archive = os.path.join(folder_in_archive, basename)
  
      self._path = os.path.join(root, folder_in_archive)
  
      if download:
          if not os.path.isdir(self._path):
              if not os.path.isfile(archive):
                  checksum = _CHECKSUMS.get(url, None)
                  download_url_to_file(
                      url, archive, hash_prefix=checksum
                  )
              _extract_tar(archive, self._path)
      else:
          if not os.path.exists(self._path):
              raise RuntimeError(
                  f"The path {self._path} doesn't exist. "
                  "Please check the ``root`` path or set `download=True` to download it"
              )
  
      if subset == "validation":
          self._walker = _load_list(self._path, "validation_list.txt")
      elif subset == "testing":
          self._walker = _load_list(self._path, "testing_list.txt")
      elif subset == "training":
          excludes = set(
              _load_list(
                  self._path, "validation_list.txt", "testing_list.txt"
              )
          )
          walker = sorted(
              str(p) for p in Path(self._path).glob("*/*.wav")
          )
          self._walker = [
              w
              for w in walker
              if HASH_DIVIDER in w
              and EXCEPT_FOLDER not in w
              and os.path.normpath(w) not in excludes
          ]
      else:
          walker = sorted(
              str(p) for p in Path(self._path).glob("*/*.wav")
          )
          self._walker = [
              w
              for w in walker
              if HASH_DIVIDER in w and EXCEPT_FOLDER not in w
          ]
  
file_path: audio/src/torchaudio/datasets/speechcommands.py
imports: import os
  from pathlib import Path
  from typing import Optional, Tuple, Union
  from torch import Tensor
  from torch.utils.data import Dataset
  from torchaudio._internal import download_url_to_file
  from torchaudio.datasets.utils import _extract_tar, _load_waveform
label_desc: Use image node_id 1 to create a new SPEECHCOMMANDS object from inherited base classes: Dataset with example: obj = SPEECHCOMMANDS(root, url, folder_in_archive, download, subset)