We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Cannot Download PCAM dataset for val split
### 🐛 Describe the bug


```

import torchvision.datasets as datasets
transform_train = transforms.Compose([
            transforms.ColorJitter(),
            transforms.RandomHorizontalFlip(),
            transforms.RandomVerticalFlip(),
            transforms.Resize(args.input_size),
            transforms.ToTensor(),
            transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]) 
        ]) 

dataset_train = datasets.PCAM(
    root = args.data_path,
    split = 'val',
    transform = transform_train,
    download=True
)
```

The error is like:


`RuntimeError: The MD5 checksum of the download file /localscratch2/xuezhiyu/datasets/pcam/camelyonpatch_level_2_split_valid_x.h5.gz does not match the one on record.Please delete the file and try again. If the issue persists, please report this to torchvision at https://github.com/pytorch/vision/issues.
`
### Versions

Collecting environment information...
PyTorch version: 1.12.1+cu113
Is debug build: False
CUDA used to build PyTorch: 11.3
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.3 LTS (x86_64)
GCC version: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Clang version: Could not collect
CMake version: version 3.16.3
Libc version: glibc-2.31

Python version: 3.8.8 (default, Apr 13 2021, 19:58:26)  [GCC 7.3.0] (64-bit runtime)
Python platform: Linux-5.13.0-27-generic-x86_64-with-glibc2.10
Is CUDA available: True
CUDA runtime version: 11.1.105
GPU models and configuration: 
GPU 0: NVIDIA RTX A5000
GPU 1: NVIDIA RTX A5000
GPU 2: NVIDIA RTX A5000
GPU 3: NVIDIA RTX A5000

Nvidia driver version: 470.57.02
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.8.3.2
/usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.3.2
/usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.3.2
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.3.2
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.3.2
/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.3.2
/usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.3.2
/usr/local/cuda-10.1/targets/x86_64-linux/lib/libcudnn.so.8.0.5
/usr/local/cuda-10.1/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8.0.5
/usr/local/cuda-10.1/targets/x86_64-linux/lib/libcudnn_adv_train.so.8.0.5
/usr/local/cuda-10.1/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8.0.5
/usr/local/cuda-10.1/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8.0.5
/usr/local/cuda-10.1/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8.0.5
/usr/local/cuda-10.1/targets/x86_64-linux/lib/libcudnn_ops_train.so.8.0.5
/usr/local/cuda-10.2/targets/x86_64-linux/lib/libcudnn.so.8.3.1
/usr/local/cuda-10.2/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8.3.1
/usr/local/cuda-10.2/targets/x86_64-linux/lib/libcudnn_adv_train.so.8.3.1
/usr/local/cuda-10.2/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8.3.1
/usr/local/cuda-10.2/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8.3.1
/usr/local/cuda-10.2/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8.3.1
/usr/local/cuda-10.2/targets/x86_64-linux/lib/libcudnn_ops_train.so.8.3.1
/usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn.so.8.2.4
/usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8.2.4
/usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_adv_train.so.8.2.4
/usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8.2.4
/usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8.2.4
/usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8.2.4
/usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_ops_train.so.8.2.4
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

Versions of relevant libraries:
[pip3] mypy-extensions==0.4.3
[pip3] numpy==1.20.1
[pip3] numpydoc==1.1.0
[pip3] torch==1.12.1+cu113
[pip3] torchaudio==0.12.1+cu113
[pip3] torchmultimodal==0.1.0a0
[pip3] torchvision==0.13.1+cu113
[conda] blas                      1.0                         mkl  
[conda] mkl                       2021.2.0           h06a4308_296  
[conda] mkl-service               2.3.0            py38h27cfd23_1  
[conda] mkl_fft                   1.3.0            py38h42c9631_2  
[conda] mkl_random                1.2.1            py38ha9443f7_2  
[conda] numpy                     1.20.1           py38h93e21f0_0  
[conda] numpy-base                1.20.1           py38h7d8b39e_0  
[conda] numpydoc                  1.1.0              pyhd3eb1b0_1  
[conda] torch                     1.12.1+cu113             pypi_0    pypi
[conda] torchaudio                0.12.1+cu113             pypi_0    pypi
[conda] torchmultimodal           0.1.0a0                   dev_0    <develop>
[conda] torchvision               0.13.1+cu113             pypi_0    pypi


cc @pmeier

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `torchvision/datasets/pcam.py`
Content:
```
1 import pathlib
2 from typing import Any, Callable, Optional, Tuple
3 
4 from PIL import Image
5 
6 from .utils import _decompress, download_file_from_google_drive, verify_str_arg
7 from .vision import VisionDataset
8 
9 
10 class PCAM(VisionDataset):
11     """`PCAM Dataset   <https://github.com/basveeling/pcam>`_.
12 
13     The PatchCamelyon dataset is a binary classification dataset with 327,680
14     color images (96px x 96px), extracted from histopathologic scans of lymph node
15     sections. Each image is annotated with a binary label indicating presence of
16     metastatic tissue.
17 
18     This dataset requires the ``h5py`` package which you can install with ``pip install h5py``.
19 
20     Args:
21          root (string): Root directory of the dataset.
22          split (string, optional): The dataset split, supports ``"train"`` (default), ``"test"`` or ``"val"``.
23          transform (callable, optional): A function/transform that  takes in a PIL image and returns a transformed
24              version. E.g, ``transforms.RandomCrop``.
25          target_transform (callable, optional): A function/transform that takes in the target and transforms it.
26          download (bool, optional): If True, downloads the dataset from the internet and puts it into ``root/pcam``. If
27              dataset is already downloaded, it is not downloaded again.
28     """
29 
30     _FILES = {
31         "train": {
32             "images": (
33                 "camelyonpatch_level_2_split_train_x.h5",  # Data file name
34                 "1Ka0XfEMiwgCYPdTI-vv6eUElOBnKFKQ2",  # Google Drive ID
35                 "1571f514728f59376b705fc836ff4b63",  # md5 hash
36             ),
37             "targets": (
38                 "camelyonpatch_level_2_split_train_y.h5",
39                 "1269yhu3pZDP8UYFQs-NYs3FPwuK-nGSG",
40                 "35c2d7259d906cfc8143347bb8e05be7",
41             ),
42         },
43         "test": {
44             "images": (
45                 "camelyonpatch_level_2_split_test_x.h5",
46                 "1qV65ZqZvWzuIVthK8eVDhIwrbnsJdbg_",
47                 "d5b63470df7cfa627aeec8b9dc0c066e",
48             ),
49             "targets": (
50                 "camelyonpatch_level_2_split_test_y.h5",
51                 "17BHrSrwWKjYsOgTMmoqrIjDy6Fa2o_gP",
52                 "2b85f58b927af9964a4c15b8f7e8f179",
53             ),
54         },
55         "val": {
56             "images": (
57                 "camelyonpatch_level_2_split_valid_x.h5",
58                 "1hgshYGWK8V-eGRy8LToWJJgDU_rXWVJ3",
59                 "d8c2d60d490dbd479f8199bdfa0cf6ec",
60             ),
61             "targets": (
62                 "camelyonpatch_level_2_split_valid_y.h5",
63                 "1bH8ZRbhSVAhScTS0p9-ZzGnX91cHT3uO",
64                 "60a7035772fbdb7f34eb86d4420cf66a",
65             ),
66         },
67     }
68 
69     def __init__(
70         self,
71         root: str,
72         split: str = "train",
73         transform: Optional[Callable] = None,
74         target_transform: Optional[Callable] = None,
75         download: bool = False,
76     ):
77         try:
78             import h5py
79 
80             self.h5py = h5py
81         except ImportError:
82             raise RuntimeError(
83                 "h5py is not found. This dataset needs to have h5py installed: please run pip install h5py"
84             )
85 
86         self._split = verify_str_arg(split, "split", ("train", "test", "val"))
87 
88         super().__init__(root, transform=transform, target_transform=target_transform)
89         self._base_folder = pathlib.Path(self.root) / "pcam"
90 
91         if download:
92             self._download()
93 
94         if not self._check_exists():
95             raise RuntimeError("Dataset not found. You can use download=True to download it")
96 
97     def __len__(self) -> int:
98         images_file = self._FILES[self._split]["images"][0]
99         with self.h5py.File(self._base_folder / images_file) as images_data:
100             return images_data["x"].shape[0]
101 
102     def __getitem__(self, idx: int) -> Tuple[Any, Any]:
103         images_file = self._FILES[self._split]["images"][0]
104         with self.h5py.File(self._base_folder / images_file) as images_data:
105             image = Image.fromarray(images_data["x"][idx]).convert("RGB")
106 
107         targets_file = self._FILES[self._split]["targets"][0]
108         with self.h5py.File(self._base_folder / targets_file) as targets_data:
109             target = int(targets_data["y"][idx, 0, 0, 0])  # shape is [num_images, 1, 1, 1]
110 
111         if self.transform:
112             image = self.transform(image)
113         if self.target_transform:
114             target = self.target_transform(target)
115 
116         return image, target
117 
118     def _check_exists(self) -> bool:
119         images_file = self._FILES[self._split]["images"][0]
120         targets_file = self._FILES[self._split]["targets"][0]
121         return all(self._base_folder.joinpath(h5_file).exists() for h5_file in (images_file, targets_file))
122 
123     def _download(self) -> None:
124         if self._check_exists():
125             return
126 
127         for file_name, file_id, md5 in self._FILES[self._split].values():
128             archive_name = file_name + ".gz"
129             download_file_from_google_drive(file_id, str(self._base_folder), filename=archive_name, md5=md5)
130             _decompress(str(self._base_folder / archive_name))
131
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/torchvision/datasets/pcam.py b/torchvision/datasets/pcam.py
--- a/torchvision/datasets/pcam.py
+++ b/torchvision/datasets/pcam.py
@@ -44,24 +44,24 @@
             "images": (
                 "camelyonpatch_level_2_split_test_x.h5",
                 "1qV65ZqZvWzuIVthK8eVDhIwrbnsJdbg_",
-                "d5b63470df7cfa627aeec8b9dc0c066e",
+                "d8c2d60d490dbd479f8199bdfa0cf6ec",
             ),
             "targets": (
                 "camelyonpatch_level_2_split_test_y.h5",
                 "17BHrSrwWKjYsOgTMmoqrIjDy6Fa2o_gP",
-                "2b85f58b927af9964a4c15b8f7e8f179",
+                "60a7035772fbdb7f34eb86d4420cf66a",
             ),
         },
         "val": {
             "images": (
                 "camelyonpatch_level_2_split_valid_x.h5",
                 "1hgshYGWK8V-eGRy8LToWJJgDU_rXWVJ3",
-                "d8c2d60d490dbd479f8199bdfa0cf6ec",
+                "d5b63470df7cfa627aeec8b9dc0c066e",
             ),
             "targets": (
                 "camelyonpatch_level_2_split_valid_y.h5",
                 "1bH8ZRbhSVAhScTS0p9-ZzGnX91cHT3uO",
-                "60a7035772fbdb7f34eb86d4420cf66a",
+                "2b85f58b927af9964a4c15b8f7e8f179",
             ),
         },
     }

{"golden_diff": "diff --git a/torchvision/datasets/pcam.py b/torchvision/datasets/pcam.py\n--- a/torchvision/datasets/pcam.py\n+++ b/torchvision/datasets/pcam.py\n@@ -44,24 +44,24 @@\n             \"images\": (\n                 \"camelyonpatch_level_2_split_test_x.h5\",\n                 \"1qV65ZqZvWzuIVthK8eVDhIwrbnsJdbg_\",\n-                \"d5b63470df7cfa627aeec8b9dc0c066e\",\n+                \"d8c2d60d490dbd479f8199bdfa0cf6ec\",\n             ),\n             \"targets\": (\n                 \"camelyonpatch_level_2_split_test_y.h5\",\n                 \"17BHrSrwWKjYsOgTMmoqrIjDy6Fa2o_gP\",\n-                \"2b85f58b927af9964a4c15b8f7e8f179\",\n+                \"60a7035772fbdb7f34eb86d4420cf66a\",\n             ),\n         },\n         \"val\": {\n             \"images\": (\n                 \"camelyonpatch_level_2_split_valid_x.h5\",\n                 \"1hgshYGWK8V-eGRy8LToWJJgDU_rXWVJ3\",\n-                \"d8c2d60d490dbd479f8199bdfa0cf6ec\",\n+                \"d5b63470df7cfa627aeec8b9dc0c066e\",\n             ),\n             \"targets\": (\n                 \"camelyonpatch_level_2_split_valid_y.h5\",\n                 \"1bH8ZRbhSVAhScTS0p9-ZzGnX91cHT3uO\",\n-                \"60a7035772fbdb7f34eb86d4420cf66a\",\n+                \"2b85f58b927af9964a4c15b8f7e8f179\",\n             ),\n         },\n     }\n", "issue": "Cannot Download PCAM dataset for val split\n### \ud83d\udc1b Describe the bug\r\n\r\n\r\n```\r\n\r\nimport torchvision.datasets as datasets\r\ntransform_train = transforms.Compose([\r\n            transforms.ColorJitter(),\r\n            transforms.RandomHorizontalFlip(),\r\n            transforms.RandomVerticalFlip(),\r\n            transforms.Resize(args.input_size),\r\n            transforms.ToTensor(),\r\n            transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]) \r\n        ]) \r\n\r\ndataset_train = datasets.PCAM(\r\n    root = args.data_path,\r\n    split = 'val',\r\n    transform = transform_train,\r\n    download=True\r\n)\r\n```\r\n\r\nThe error is like:\r\n\r\n\r\n`RuntimeError: The MD5 checksum of the download file /localscratch2/xuezhiyu/datasets/pcam/camelyonpatch_level_2_split_valid_x.h5.gz does not match the one on record.Please delete the file and try again. If the issue persists, please report this to torchvision at https://github.com/pytorch/vision/issues.\r\n`\r\n### Versions\r\n\r\nCollecting environment information...\r\nPyTorch version: 1.12.1+cu113\r\nIs debug build: False\r\nCUDA used to build PyTorch: 11.3\r\nROCM used to build PyTorch: N/A\r\n\r\nOS: Ubuntu 20.04.3 LTS (x86_64)\r\nGCC version: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0\r\nClang version: Could not collect\r\nCMake version: version 3.16.3\r\nLibc version: glibc-2.31\r\n\r\nPython version: 3.8.8 (default, Apr 13 2021, 19:58:26)  [GCC 7.3.0] (64-bit runtime)\r\nPython platform: Linux-5.13.0-27-generic-x86_64-with-glibc2.10\r\nIs CUDA available: True\r\nCUDA runtime version: 11.1.105\r\nGPU models and configuration: \r\nGPU 0: NVIDIA RTX A5000\r\nGPU 1: NVIDIA RTX A5000\r\nGPU 2: NVIDIA RTX A5000\r\nGPU 3: NVIDIA RTX A5000\r\n\r\nNvidia driver version: 470.57.02\r\ncuDNN version: Probably one of the following:\r\n/usr/lib/x86_64-linux-gnu/libcudnn.so.8.3.2\r\n/usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.3.2\r\n/usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.3.2\r\n/usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.3.2\r\n/usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.3.2\r\n/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.3.2\r\n/usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.3.2\r\n/usr/local/cuda-10.1/targets/x86_64-linux/lib/libcudnn.so.8.0.5\r\n/usr/local/cuda-10.1/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8.0.5\r\n/usr/local/cuda-10.1/targets/x86_64-linux/lib/libcudnn_adv_train.so.8.0.5\r\n/usr/local/cuda-10.1/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8.0.5\r\n/usr/local/cuda-10.1/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8.0.5\r\n/usr/local/cuda-10.1/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8.0.5\r\n/usr/local/cuda-10.1/targets/x86_64-linux/lib/libcudnn_ops_train.so.8.0.5\r\n/usr/local/cuda-10.2/targets/x86_64-linux/lib/libcudnn.so.8.3.1\r\n/usr/local/cuda-10.2/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8.3.1\r\n/usr/local/cuda-10.2/targets/x86_64-linux/lib/libcudnn_adv_train.so.8.3.1\r\n/usr/local/cuda-10.2/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8.3.1\r\n/usr/local/cuda-10.2/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8.3.1\r\n/usr/local/cuda-10.2/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8.3.1\r\n/usr/local/cuda-10.2/targets/x86_64-linux/lib/libcudnn_ops_train.so.8.3.1\r\n/usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn.so.8.2.4\r\n/usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8.2.4\r\n/usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_adv_train.so.8.2.4\r\n/usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8.2.4\r\n/usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8.2.4\r\n/usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8.2.4\r\n/usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_ops_train.so.8.2.4\r\nHIP runtime version: N/A\r\nMIOpen runtime version: N/A\r\nIs XNNPACK available: True\r\n\r\nVersions of relevant libraries:\r\n[pip3] mypy-extensions==0.4.3\r\n[pip3] numpy==1.20.1\r\n[pip3] numpydoc==1.1.0\r\n[pip3] torch==1.12.1+cu113\r\n[pip3] torchaudio==0.12.1+cu113\r\n[pip3] torchmultimodal==0.1.0a0\r\n[pip3] torchvision==0.13.1+cu113\r\n[conda] blas                      1.0                         mkl  \r\n[conda] mkl                       2021.2.0           h06a4308_296  \r\n[conda] mkl-service               2.3.0            py38h27cfd23_1  \r\n[conda] mkl_fft                   1.3.0            py38h42c9631_2  \r\n[conda] mkl_random                1.2.1            py38ha9443f7_2  \r\n[conda] numpy                     1.20.1           py38h93e21f0_0  \r\n[conda] numpy-base                1.20.1           py38h7d8b39e_0  \r\n[conda] numpydoc                  1.1.0              pyhd3eb1b0_1  \r\n[conda] torch                     1.12.1+cu113             pypi_0    pypi\r\n[conda] torchaudio                0.12.1+cu113             pypi_0    pypi\r\n[conda] torchmultimodal           0.1.0a0                   dev_0    <develop>\r\n[conda] torchvision               0.13.1+cu113             pypi_0    pypi\r\n\n\ncc @pmeier\n", "before_files": [{"content": "import pathlib\nfrom typing import Any, Callable, Optional, Tuple\n\nfrom PIL import Image\n\nfrom .utils import _decompress, download_file_from_google_drive, verify_str_arg\nfrom .vision import VisionDataset\n\n\nclass PCAM(VisionDataset):\n    \"\"\"`PCAM Dataset   <https://github.com/basveeling/pcam>`_.\n\n    The PatchCamelyon dataset is a binary classification dataset with 327,680\n    color images (96px x 96px), extracted from histopathologic scans of lymph node\n    sections. Each image is annotated with a binary label indicating presence of\n    metastatic tissue.\n\n    This dataset requires the ``h5py`` package which you can install with ``pip install h5py``.\n\n    Args:\n         root (string): Root directory of the dataset.\n         split (string, optional): The dataset split, supports ``\"train\"`` (default), ``\"test\"`` or ``\"val\"``.\n         transform (callable, optional): A function/transform that  takes in a PIL image and returns a transformed\n             version. E.g, ``transforms.RandomCrop``.\n         target_transform (callable, optional): A function/transform that takes in the target and transforms it.\n         download (bool, optional): If True, downloads the dataset from the internet and puts it into ``root/pcam``. If\n             dataset is already downloaded, it is not downloaded again.\n    \"\"\"\n\n    _FILES = {\n        \"train\": {\n            \"images\": (\n                \"camelyonpatch_level_2_split_train_x.h5\",  # Data file name\n                \"1Ka0XfEMiwgCYPdTI-vv6eUElOBnKFKQ2\",  # Google Drive ID\n                \"1571f514728f59376b705fc836ff4b63\",  # md5 hash\n            ),\n            \"targets\": (\n                \"camelyonpatch_level_2_split_train_y.h5\",\n                \"1269yhu3pZDP8UYFQs-NYs3FPwuK-nGSG\",\n                \"35c2d7259d906cfc8143347bb8e05be7\",\n            ),\n        },\n        \"test\": {\n            \"images\": (\n                \"camelyonpatch_level_2_split_test_x.h5\",\n                \"1qV65ZqZvWzuIVthK8eVDhIwrbnsJdbg_\",\n                \"d5b63470df7cfa627aeec8b9dc0c066e\",\n            ),\n            \"targets\": (\n                \"camelyonpatch_level_2_split_test_y.h5\",\n                \"17BHrSrwWKjYsOgTMmoqrIjDy6Fa2o_gP\",\n                \"2b85f58b927af9964a4c15b8f7e8f179\",\n            ),\n        },\n        \"val\": {\n            \"images\": (\n                \"camelyonpatch_level_2_split_valid_x.h5\",\n                \"1hgshYGWK8V-eGRy8LToWJJgDU_rXWVJ3\",\n                \"d8c2d60d490dbd479f8199bdfa0cf6ec\",\n            ),\n            \"targets\": (\n                \"camelyonpatch_level_2_split_valid_y.h5\",\n                \"1bH8ZRbhSVAhScTS0p9-ZzGnX91cHT3uO\",\n                \"60a7035772fbdb7f34eb86d4420cf66a\",\n            ),\n        },\n    }\n\n    def __init__(\n        self,\n        root: str,\n        split: str = \"train\",\n        transform: Optional[Callable] = None,\n        target_transform: Optional[Callable] = None,\n        download: bool = False,\n    ):\n        try:\n            import h5py\n\n            self.h5py = h5py\n        except ImportError:\n            raise RuntimeError(\n                \"h5py is not found. This dataset needs to have h5py installed: please run pip install h5py\"\n            )\n\n        self._split = verify_str_arg(split, \"split\", (\"train\", \"test\", \"val\"))\n\n        super().__init__(root, transform=transform, target_transform=target_transform)\n        self._base_folder = pathlib.Path(self.root) / \"pcam\"\n\n        if download:\n            self._download()\n\n        if not self._check_exists():\n            raise RuntimeError(\"Dataset not found. You can use download=True to download it\")\n\n    def __len__(self) -> int:\n        images_file = self._FILES[self._split][\"images\"][0]\n        with self.h5py.File(self._base_folder / images_file) as images_data:\n            return images_data[\"x\"].shape[0]\n\n    def __getitem__(self, idx: int) -> Tuple[Any, Any]:\n        images_file = self._FILES[self._split][\"images\"][0]\n        with self.h5py.File(self._base_folder / images_file) as images_data:\n            image = Image.fromarray(images_data[\"x\"][idx]).convert(\"RGB\")\n\n        targets_file = self._FILES[self._split][\"targets\"][0]\n        with self.h5py.File(self._base_folder / targets_file) as targets_data:\n            target = int(targets_data[\"y\"][idx, 0, 0, 0])  # shape is [num_images, 1, 1, 1]\n\n        if self.transform:\n            image = self.transform(image)\n        if self.target_transform:\n            target = self.target_transform(target)\n\n        return image, target\n\n    def _check_exists(self) -> bool:\n        images_file = self._FILES[self._split][\"images\"][0]\n        targets_file = self._FILES[self._split][\"targets\"][0]\n        return all(self._base_folder.joinpath(h5_file).exists() for h5_file in (images_file, targets_file))\n\n    def _download(self) -> None:\n        if self._check_exists():\n            return\n\n        for file_name, file_id, md5 in self._FILES[self._split].values():\n            archive_name = file_name + \".gz\"\n            download_file_from_google_drive(file_id, str(self._base_folder), filename=archive_name, md5=md5)\n            _decompress(str(self._base_folder / archive_name))\n", "path": "torchvision/datasets/pcam.py"}], "after_files": [{"content": "import pathlib\nfrom typing import Any, Callable, Optional, Tuple\n\nfrom PIL import Image\n\nfrom .utils import _decompress, download_file_from_google_drive, verify_str_arg\nfrom .vision import VisionDataset\n\n\nclass PCAM(VisionDataset):\n    \"\"\"`PCAM Dataset   <https://github.com/basveeling/pcam>`_.\n\n    The PatchCamelyon dataset is a binary classification dataset with 327,680\n    color images (96px x 96px), extracted from histopathologic scans of lymph node\n    sections. Each image is annotated with a binary label indicating presence of\n    metastatic tissue.\n\n    This dataset requires the ``h5py`` package which you can install with ``pip install h5py``.\n\n    Args:\n         root (string): Root directory of the dataset.\n         split (string, optional): The dataset split, supports ``\"train\"`` (default), ``\"test\"`` or ``\"val\"``.\n         transform (callable, optional): A function/transform that  takes in a PIL image and returns a transformed\n             version. E.g, ``transforms.RandomCrop``.\n         target_transform (callable, optional): A function/transform that takes in the target and transforms it.\n         download (bool, optional): If True, downloads the dataset from the internet and puts it into ``root/pcam``. If\n             dataset is already downloaded, it is not downloaded again.\n    \"\"\"\n\n    _FILES = {\n        \"train\": {\n            \"images\": (\n                \"camelyonpatch_level_2_split_train_x.h5\",  # Data file name\n                \"1Ka0XfEMiwgCYPdTI-vv6eUElOBnKFKQ2\",  # Google Drive ID\n                \"1571f514728f59376b705fc836ff4b63\",  # md5 hash\n            ),\n            \"targets\": (\n                \"camelyonpatch_level_2_split_train_y.h5\",\n                \"1269yhu3pZDP8UYFQs-NYs3FPwuK-nGSG\",\n                \"35c2d7259d906cfc8143347bb8e05be7\",\n            ),\n        },\n        \"test\": {\n            \"images\": (\n                \"camelyonpatch_level_2_split_test_x.h5\",\n                \"1qV65ZqZvWzuIVthK8eVDhIwrbnsJdbg_\",\n                \"d8c2d60d490dbd479f8199bdfa0cf6ec\",\n            ),\n            \"targets\": (\n                \"camelyonpatch_level_2_split_test_y.h5\",\n                \"17BHrSrwWKjYsOgTMmoqrIjDy6Fa2o_gP\",\n                \"60a7035772fbdb7f34eb86d4420cf66a\",\n            ),\n        },\n        \"val\": {\n            \"images\": (\n                \"camelyonpatch_level_2_split_valid_x.h5\",\n                \"1hgshYGWK8V-eGRy8LToWJJgDU_rXWVJ3\",\n                \"d5b63470df7cfa627aeec8b9dc0c066e\",\n            ),\n            \"targets\": (\n                \"camelyonpatch_level_2_split_valid_y.h5\",\n                \"1bH8ZRbhSVAhScTS0p9-ZzGnX91cHT3uO\",\n                \"2b85f58b927af9964a4c15b8f7e8f179\",\n            ),\n        },\n    }\n\n    def __init__(\n        self,\n        root: str,\n        split: str = \"train\",\n        transform: Optional[Callable] = None,\n        target_transform: Optional[Callable] = None,\n        download: bool = False,\n    ):\n        try:\n            import h5py\n\n            self.h5py = h5py\n        except ImportError:\n            raise RuntimeError(\n                \"h5py is not found. This dataset needs to have h5py installed: please run pip install h5py\"\n            )\n\n        self._split = verify_str_arg(split, \"split\", (\"train\", \"test\", \"val\"))\n\n        super().__init__(root, transform=transform, target_transform=target_transform)\n        self._base_folder = pathlib.Path(self.root) / \"pcam\"\n\n        if download:\n            self._download()\n\n        if not self._check_exists():\n            raise RuntimeError(\"Dataset not found. You can use download=True to download it\")\n\n    def __len__(self) -> int:\n        images_file = self._FILES[self._split][\"images\"][0]\n        with self.h5py.File(self._base_folder / images_file) as images_data:\n            return images_data[\"x\"].shape[0]\n\n    def __getitem__(self, idx: int) -> Tuple[Any, Any]:\n        images_file = self._FILES[self._split][\"images\"][0]\n        with self.h5py.File(self._base_folder / images_file) as images_data:\n            image = Image.fromarray(images_data[\"x\"][idx]).convert(\"RGB\")\n\n        targets_file = self._FILES[self._split][\"targets\"][0]\n        with self.h5py.File(self._base_folder / targets_file) as targets_data:\n            target = int(targets_data[\"y\"][idx, 0, 0, 0])  # shape is [num_images, 1, 1, 1]\n\n        if self.transform:\n            image = self.transform(image)\n        if self.target_transform:\n            target = self.target_transform(target)\n\n        return image, target\n\n    def _check_exists(self) -> bool:\n        images_file = self._FILES[self._split][\"images\"][0]\n        targets_file = self._FILES[self._split][\"targets\"][0]\n        return all(self._base_folder.joinpath(h5_file).exists() for h5_file in (images_file, targets_file))\n\n    def _download(self) -> None:\n        if self._check_exists():\n            return\n\n        for file_name, file_id, md5 in self._FILES[self._split].values():\n            archive_name = file_name + \".gz\"\n            download_file_from_google_drive(file_id, str(self._base_folder), filename=archive_name, md5=md5)\n            _decompress(str(self._base_folder / archive_name))\n", "path": "torchvision/datasets/pcam.py"}]}