class_docstr: The Dataset to automatically download the data of Medical Segmentation Decathlon challenge
  (http://medicaldecathlon.com/) and generate items for training, validation or test.
  It will also load these properties from the JSON config file of dataset. user can call `get_properties()`
  to get specified properties or all the properties loaded.
  It's based on :py:class:`monai.data.CacheDataset` to accelerate the training process.
  
  Args:
      root_dir: user's local directory for caching and loading the MSD datasets.
      task: which task to download and execute: one of list ("Task01_BrainTumour", "Task02_Heart",
          "Task03_Liver", "Task04_Hippocampus", "Task05_Prostate", "Task06_Lung", "Task07_Pancreas",
          "Task08_HepaticVessel", "Task09_Spleen", "Task10_Colon").
      section: expected data section, can be: `training`, `validation` or `test`.
      transform: transforms to execute operations on input data.
          for further usage, use `EnsureChannelFirstd` to convert the shape to [C, H, W, D].
      download: whether to download and extract the Decathlon from resource link, default is False.
          if expected file already exists, skip downloading even set it to True.
          user can manually copy tar file or dataset folder to the root directory.
      val_frac: percentage of validation fraction in the whole dataset, default is 0.2.
      seed: random seed to randomly shuffle the datalist before splitting into training and validation, default is 0.
          note to set same seed for `training` and `validation` sections.
      cache_num: number of items to be cached. Default is `sys.maxsize`.
          will take the minimum of (cache_num, data_length x cache_rate, data_length).
      cache_rate: percentage of cached data in total, default is 1.0 (cache all).
          will take the minimum of (cache_num, data_length x cache_rate, data_length).
      num_workers: the number of worker threads if computing cache in the initialization.
          If num_workers is None then the number returned by os.cpu_count() is used.
          If a value less than 1 is specified, 1 will be used instead.
      progress: whether to display a progress bar when downloading dataset and computing the transform cache content.
      copy_cache: whether to `deepcopy` the cache content before applying the random transforms,
          default to `True`. if the random transforms don't modify the cached content
          (for example, randomly crop from the cached image and deepcopy the crop region)
          or if every cache item is only used once in a `multi-processing` environment,
          may set `copy=False` for better performance.
      as_contiguous: whether to convert the cached NumPy array or PyTorch tensor to be contiguous.
          it may help improve the performance of following logic.
      runtime_cache: whether to compute cache at the runtime, default to `False` to prepare
          the cache content at initialization. See: :py:class:`monai.data.CacheDataset`.
  
  Raises:
      ValueError: When ``root_dir`` is not a directory.
      ValueError: When ``task`` is not one of ["Task01_BrainTumour", "Task02_Heart",
          "Task03_Liver", "Task04_Hippocampus", "Task05_Prostate", "Task06_Lung", "Task07_Pancreas",
          "Task08_HepaticVessel", "Task09_Spleen", "Task10_Colon"].
      RuntimeError: When ``dataset_dir`` doesn't exist and downloading is not selected (``download=False``).
  
  Example::
  
      transform = Compose(
          [
              LoadImaged(keys=["image", "label"]),
              EnsureChannelFirstd(keys=["image", "label"]),
              ScaleIntensityd(keys="image"),
              ToTensord(keys=["image", "label"]),
          ]
      )
  
      val_data = DecathlonDataset(
          root_dir="./", task="Task09_Spleen", transform=transform, section="validation", seed=12345, download=True
      )
  
      print(val_data[0]["image"], val_data[0]["label"])
class_docstr_tok: ["The","Dataset","to","automatically","download","the","data","of","Medical","Segmentation","Decathlon","challenge","(","http",":","\/\/medicaldecathlon.com\/",")","and","generate","items","for","training",",","validation","or","test",".","It","will","also","load","these","properties","from","the","JSON","config","file","of","dataset",".","user","can","call","`","get_properties","(",")","`","to","get","specified","properties","or","all","the","properties","loaded",".","It","'s","based","on",":","py",":","class",":","`","monai.data.CacheDataset","`","to","accelerate","the","training","process",".","Args",":","root_dir",":","user","'s","local","directory","for","caching","and","loading","the","MSD","datasets",".","task",":","which","task","to","download","and","execute",":","one","of","list","(","``","Task01_BrainTumour","''",",","``","Task02_Heart","''",",","``","Task03_Liver","''",",","``","Task04_Hippocampus","''",",","``","Task05_Prostate","''",",","``","Task06_Lung","''",",","``","Task07_Pancreas","''",",","``","Task08_HepaticVessel","''",",","``","Task09_Spleen","''",",","``","Task10_Colon","''",")",".","section",":","expected","data","section",",","can","be",":","`","training","`",",","`","validation","`","or","`","test","`",".","transform",":","transforms","to","execute","operations","on","input","data",".","for","further","usage",",","use","`","EnsureChannelFirstd","`","to","convert","the","shape","to","[","C",",","H",",","W",",","D","]",".","download",":","whether","to","download","and","extract","the","Decathlon","from","resource","link",",","default","is","False",".","if","expected","file","already","exists",",","skip","downloading","even","set","it","to","True",".","user","can","manually","copy","tar","file","or","dataset","folder","to","the","root","directory",".","val_frac",":","percentage","of","validation","fraction","in","the","whole","dataset",",","default","is","0.2.","seed",":","random","seed","to","randomly","shuffle","the","datalist","before","splitting","into","training","and","validation",",","default","is","0.","note","to","set","same","seed","for","`","training","`","and","`","validation","`","sections",".","cache_num",":","number","of","items","to","be","cached",".","Default","is","`","sys.maxsize","`",".","will","take","the","minimum","of","(","cache_num",",","data_length","x","cache_rate",",","data_length",")",".","cache_rate",":","percentage","of","cached","data","in","total",",","default","is","1.0","(","cache","all",")",".","will","take","the","minimum","of","(","cache_num",",","data_length","x","cache_rate",",","data_length",")",".","num_workers",":","the","number","of","worker","threads","if","computing","cache","in","the","initialization",".","If","num_workers","is","None","then","the","number","returned","by","os.cpu_count","(",")","is","used",".","If","a","value","less","than","1","is","specified",",","1","will","be","used","instead",".","progress",":","whether","to","display","a","progress","bar","when","downloading","dataset","and","computing","the","transform","cache","content",".","copy_cache",":","whether","to","`","deepcopy","`","the","cache","content","before","applying","the","random","transforms",",","default","to","`","True","`",".","if","the","random","transforms","do","n't","modify","the","cached","content","(","for","example",",","randomly","crop","from","the","cached","image","and","deepcopy","the","crop","region",")","or","if","every","cache","item","is","only","used","once","in","a","`","multi-processing","`","environment",",","may","set","`","copy=False","`","for","better","performance",".","as_contiguous",":","whether","to","convert","the","cached","NumPy","array","or","PyTorch","tensor","to","be","contiguous",".","it","may","help","improve","the","performance","of","following","logic",".","runtime_cache",":","whether","to","compute","cache","at","the","runtime",",","default","to","`","False","`","to","prepare","the","cache","content","at","initialization",".","See",":",":","py",":","class",":","`","monai.data.CacheDataset","`",".","Raises",":","ValueError",":","When","``","root_dir","``","is","not","a","directory",".","ValueError",":","When","``","task","``","is","not","one","of","[","``","Task01_BrainTumour","''",",","``","Task02_Heart","''",",","``","Task03_Liver","''",",","``","Task04_Hippocampus","''",",","``","Task05_Prostate","''",",","``","Task06_Lung","''",",","``","Task07_Pancreas","''",",","``","Task08_HepaticVessel","''",",","``","Task09_Spleen","''",",","``","Task10_Colon","''","]",".","RuntimeError",":","When","``","dataset_dir","``","does","n't","exist","and","downloading","is","not","selected","(","``","download=False","``",")",".","Example",":",":","transform","=","Compose","(","[","LoadImaged","(","keys=","[","``","image","''",",","``","label","''","]",")",",","EnsureChannelFirstd","(","keys=","[","``","image","''",",","``","label","''","]",")",",","ScaleIntensityd","(","keys=","''","image","''",")",",","ToTensord","(","keys=","[","``","image","''",",","``","label","''","]",")",",","]",")","val_data","=","DecathlonDataset","(","root_dir=","''",".\/","''",",","task=","''","Task09_Spleen","''",",","transform=transform",",","section=","''","validation","''",",","seed=12345",",","download=True",")","print","(","val_data","[","0","]","[","``","image","''","]",",","val_data","[","0","]","[","``","label","''","]",")"]
code: def __init__(
      self,
      root_dir: PathLike,
      task: str,
      section: str,
      transform: Sequence[Callable] | Callable = (),
      download: bool = False,
      seed: int = 0,
      val_frac: float = 0.2,
      cache_num: int = sys.maxsize,
      cache_rate: float = 1.0,
      num_workers: int = 1,
      progress: bool = True,
      copy_cache: bool = True,
      as_contiguous: bool = True,
      runtime_cache: bool = False,
  ) -> None:
      root_dir = Path(root_dir)
      if not root_dir.is_dir():
          raise ValueError(
              "Root directory root_dir must be a directory."
          )
      self.section = section
      self.val_frac = val_frac
      self.set_random_state(seed=seed)
      if task not in self.resource:
          raise ValueError(
              f"Unsupported task: {task}, available options are: {list(self.resource.keys())}."
          )
      dataset_dir = root_dir / task
      tarfile_name = f"{dataset_dir}.tar"
      if download:
          download_and_extract(
              url=self.resource[task],
              filepath=tarfile_name,
              output_dir=root_dir,
              hash_val=self.md5[task],
              hash_type="md5",
              progress=progress,
          )
  
      if not dataset_dir.exists():
          raise RuntimeError(
              f"Cannot find dataset directory: {dataset_dir}, please use download=True to download it."
          )
      self.indices: np.ndarray = np.array([])
      data = self._generate_data_list(dataset_dir)
      # as `release` key has typo in Task04 config file, ignore it.
      property_keys = [
          "name",
          "description",
          "reference",
          "licence",
          "tensorImageSize",
          "modality",
          "labels",
          "numTraining",
          "numTest",
      ]
      self._properties = load_decathlon_properties(
          dataset_dir / "dataset.json", property_keys
      )
      if transform == ():
          transform = LoadImaged(["image", "label"])
      CacheDataset.__init__(
          self,
          data=data,
          transform=transform,
          cache_num=cache_num,
          cache_rate=cache_rate,
          num_workers=num_workers,
          progress=progress,
          copy_cache=copy_cache,
          as_contiguous=as_contiguous,
          runtime_cache=runtime_cache,
      )
  
imports: from __future__ import annotations
  import os
  import shutil
  import sys
  import warnings
  from collections.abc import Callable, Sequence
  from pathlib import Path
  from typing import Any
  import numpy
  from monai.apps.tcia import DCM_FILENAME_REGEX, download_tcia_series_instance, get_tcia_metadata, get_tcia_ref_uid, match_tcia_ref_uid_in_study
  from monai.apps.utils import download_and_extract
  from monai.config.type_definitions import PathLike
  from monai.data import CacheDataset, PydicomReader, load_decathlon_datalist, load_decathlon_properties, partition_dataset, select_cross_validation_folds
  from monai.transforms import LoadImaged, Randomizable
  from monai.utils import ensure_tuple
label_desc: Use image node_id 1 to create a new DecathlonDataset object from inherited base classes: Randomizable, CacheDataset with example: obj = DecathlonDataset(root_dir, task, section, transform, download, seed, val_frac, cache_num, cache_rate, num_workers, progress, copy_cache, as_contiguous, runtime_cache)