We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Dataset MovingMNIST: `split=None` returns test dataset
### 🐛 Describe the bug

I've found a bug in the code for torchvision's MovingMNIST dataset, which causes only the test dataset to be returned when split=None. According to the documentation, when split is set to None, the entire dataset should be returned. However, this is not currently happening.
https://github.com/pytorch/vision/blob/b403bfc771e0caf31efd06d43860b09004f4ac61/torchvision/datasets/moving_mnist.py#L13-L19

I've tested this with the following code:
```python
from torchvision import datasets
import torch

dataset = datasets.MovingMNIST(root="data", download=True)
dataset[0].size() # returns torch.Size([10, 1, 64, 64]), but I expected torch.Size([20, 1, 64, 64])
```

I believe the bug is caused by lines 58-62 in the code, which handle None and test splits together:
https://github.com/pytorch/vision/blob/b403bfc771e0caf31efd06d43860b09004f4ac61/torchvision/datasets/moving_mnist.py#L42-L62

To fix this, I propose the following two changes:
- Separate the handling of None and test splits in the code.
- Only process lines 46-50 when split is not None.

Reference issue: #6981 

I'm happy to help on this issue, please assign to me on this one.

### Versions

PyTorch version: 2.0.0
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: macOS 13.2.1 (arm64)
GCC version: Could not collect
Clang version: 14.0.0 (clang-1400.0.29.202)
CMake version: Could not collect
Libc version: N/A

Python version: 3.10.9 | packaged by conda-forge | (main, Feb  2 2023, 20:26:08) [Clang 14.0.6 ] (64-bit runtime)
Python platform: macOS-13.2.1-arm64-arm-64bit
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Apple M1 Pro

Versions of relevant libraries:
[pip3] mypy-extensions==1.0.0
[pip3] numpy==1.24.2
[pip3] torch==2.0.0
[pip3] torch-tb-profiler==0.4.1
[pip3] torchvision==0.15.1
[conda] numpy                     1.24.2          py310h3d2048e_0    conda-forge
[conda] pytorch                   2.0.0                  py3.10_0    pytorch
[conda] torch                     2.0.0                    pypi_0    pypi
[conda] torch-tb-profiler         0.4.1                    pypi_0    pypi
[conda] torchvision               0.15.1                   pypi_0    pypi

cc @pmeier
Dataset MovingMNIST: `split=None` returns test dataset
### 🐛 Describe the bug

I've found a bug in the code for torchvision's MovingMNIST dataset, which causes only the test dataset to be returned when split=None. According to the documentation, when split is set to None, the entire dataset should be returned. However, this is not currently happening.
https://github.com/pytorch/vision/blob/b403bfc771e0caf31efd06d43860b09004f4ac61/torchvision/datasets/moving_mnist.py#L13-L19

I've tested this with the following code:
```python
from torchvision import datasets
import torch

dataset = datasets.MovingMNIST(root="data", download=True)
dataset[0].size() # returns torch.Size([10, 1, 64, 64]), but I expected torch.Size([20, 1, 64, 64])
```

I believe the bug is caused by lines 58-62 in the code, which handle None and test splits together:
https://github.com/pytorch/vision/blob/b403bfc771e0caf31efd06d43860b09004f4ac61/torchvision/datasets/moving_mnist.py#L42-L62

To fix this, I propose the following two changes:
- Separate the handling of None and test splits in the code.
- Only process lines 46-50 when split is not None.

Reference issue: #6981 

I'm happy to help on this issue, please assign to me on this one.

### Versions

PyTorch version: 2.0.0
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: macOS 13.2.1 (arm64)
GCC version: Could not collect
Clang version: 14.0.0 (clang-1400.0.29.202)
CMake version: Could not collect
Libc version: N/A

Python version: 3.10.9 | packaged by conda-forge | (main, Feb  2 2023, 20:26:08) [Clang 14.0.6 ] (64-bit runtime)
Python platform: macOS-13.2.1-arm64-arm-64bit
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Apple M1 Pro

Versions of relevant libraries:
[pip3] mypy-extensions==1.0.0
[pip3] numpy==1.24.2
[pip3] torch==2.0.0
[pip3] torch-tb-profiler==0.4.1
[pip3] torchvision==0.15.1
[conda] numpy                     1.24.2          py310h3d2048e_0    conda-forge
[conda] pytorch                   2.0.0                  py3.10_0    pytorch
[conda] torch                     2.0.0                    pypi_0    pypi
[conda] torch-tb-profiler         0.4.1                    pypi_0    pypi
[conda] torchvision               0.15.1                   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/moving_mnist.py`
Content:
```
1 import os.path
2 from typing import Callable, Optional
3 
4 import numpy as np
5 import torch
6 from torchvision.datasets.utils import download_url, verify_str_arg
7 from torchvision.datasets.vision import VisionDataset
8 
9 
10 class MovingMNIST(VisionDataset):
11     """`MovingMNIST <http://www.cs.toronto.edu/~nitish/unsupervised_video/>`_ Dataset.
12 
13     Args:
14         root (string): Root directory of dataset where ``MovingMNIST/mnist_test_seq.npy`` exists.
15         split (string, optional): The dataset split, supports ``None`` (default), ``"train"`` and ``"test"``.
16             If ``split=None``, the full data is returned.
17         split_ratio (int, optional): The split ratio of number of frames. If ``split="train"``, the first split
18             frames ``data[:, :split_ratio]`` is returned. If ``split="test"``, the last split frames ``data[:, split_ratio:]``
19             is returned. If ``split=None``, this parameter is ignored and the all frames data is returned.
20         transform (callable, optional): A function/transform that takes in an torch Tensor
21             and returns a transformed version. E.g, ``transforms.RandomCrop``
22         download (bool, optional): If true, downloads the dataset from the internet and
23             puts it in root directory. If dataset is already downloaded, it is not
24             downloaded again.
25     """
26 
27     _URL = "http://www.cs.toronto.edu/~nitish/unsupervised_video/mnist_test_seq.npy"
28 
29     def __init__(
30         self,
31         root: str,
32         split: Optional[str] = None,
33         split_ratio: int = 10,
34         download: bool = False,
35         transform: Optional[Callable] = None,
36     ) -> None:
37         super().__init__(root, transform=transform)
38 
39         self._base_folder = os.path.join(self.root, self.__class__.__name__)
40         self._filename = self._URL.split("/")[-1]
41 
42         if split is not None:
43             verify_str_arg(split, "split", ("train", "test"))
44         self.split = split
45 
46         if not isinstance(split_ratio, int):
47             raise TypeError(f"`split_ratio` should be an integer, but got {type(split_ratio)}")
48         elif not (1 <= split_ratio <= 19):
49             raise ValueError(f"`split_ratio` should be `1 <= split_ratio <= 19`, but got {split_ratio} instead.")
50         self.split_ratio = split_ratio
51 
52         if download:
53             self.download()
54 
55         if not self._check_exists():
56             raise RuntimeError("Dataset not found. You can use download=True to download it.")
57 
58         data = torch.from_numpy(np.load(os.path.join(self._base_folder, self._filename)))
59         if self.split == "train":
60             data = data[: self.split_ratio]
61         else:
62             data = data[self.split_ratio :]
63         self.data = data.transpose(0, 1).unsqueeze(2).contiguous()
64 
65     def __getitem__(self, idx: int) -> torch.Tensor:
66         """
67         Args:
68             index (int): Index
69         Returns:
70             torch.Tensor: Video frames (torch Tensor[T, C, H, W]). The `T` is the number of frames.
71         """
72         data = self.data[idx]
73         if self.transform is not None:
74             data = self.transform(data)
75 
76         return data
77 
78     def __len__(self) -> int:
79         return len(self.data)
80 
81     def _check_exists(self) -> bool:
82         return os.path.exists(os.path.join(self._base_folder, self._filename))
83 
84     def download(self) -> None:
85         if self._check_exists():
86             return
87 
88         download_url(
89             url=self._URL,
90             root=self._base_folder,
91             filename=self._filename,
92             md5="be083ec986bfe91a449d63653c411eb2",
93         )
94
```
--- 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/moving_mnist.py b/torchvision/datasets/moving_mnist.py
--- a/torchvision/datasets/moving_mnist.py
+++ b/torchvision/datasets/moving_mnist.py
@@ -58,7 +58,7 @@
         data = torch.from_numpy(np.load(os.path.join(self._base_folder, self._filename)))
         if self.split == "train":
             data = data[: self.split_ratio]
-        else:
+        elif self.split == "test":
             data = data[self.split_ratio :]
         self.data = data.transpose(0, 1).unsqueeze(2).contiguous()

{"golden_diff": "diff --git a/torchvision/datasets/moving_mnist.py b/torchvision/datasets/moving_mnist.py\n--- a/torchvision/datasets/moving_mnist.py\n+++ b/torchvision/datasets/moving_mnist.py\n@@ -58,7 +58,7 @@\n         data = torch.from_numpy(np.load(os.path.join(self._base_folder, self._filename)))\n         if self.split == \"train\":\n             data = data[: self.split_ratio]\n-        else:\n+        elif self.split == \"test\":\n             data = data[self.split_ratio :]\n         self.data = data.transpose(0, 1).unsqueeze(2).contiguous()\n", "issue": "Dataset MovingMNIST: `split=None` returns test dataset\n### \ud83d\udc1b Describe the bug\n\nI've found a bug in the code for torchvision's MovingMNIST dataset, which causes only the test dataset to be returned when split=None. According to the documentation, when split is set to None, the entire dataset should be returned. However, this is not currently happening.\r\nhttps://github.com/pytorch/vision/blob/b403bfc771e0caf31efd06d43860b09004f4ac61/torchvision/datasets/moving_mnist.py#L13-L19\r\n\r\nI've tested this with the following code:\r\n```python\r\nfrom torchvision import datasets\r\nimport torch\r\n\r\ndataset = datasets.MovingMNIST(root=\"data\", download=True)\r\ndataset[0].size() # returns torch.Size([10, 1, 64, 64]), but I expected torch.Size([20, 1, 64, 64])\r\n```\r\n\r\nI believe the bug is caused by lines 58-62 in the code, which handle None and test splits together:\r\nhttps://github.com/pytorch/vision/blob/b403bfc771e0caf31efd06d43860b09004f4ac61/torchvision/datasets/moving_mnist.py#L42-L62\r\n\r\nTo fix this, I propose the following two changes:\r\n- Separate the handling of None and test splits in the code.\r\n- Only process lines 46-50 when split is not None.\r\n\r\nReference issue: #6981 \r\n\r\nI'm happy to help on this issue, please assign to me on this one.\n\n### Versions\n\nPyTorch version: 2.0.0\r\nIs debug build: False\r\nCUDA used to build PyTorch: None\r\nROCM used to build PyTorch: N/A\r\n\r\nOS: macOS 13.2.1 (arm64)\r\nGCC version: Could not collect\r\nClang version: 14.0.0 (clang-1400.0.29.202)\r\nCMake version: Could not collect\r\nLibc version: N/A\r\n\r\nPython version: 3.10.9 | packaged by conda-forge | (main, Feb  2 2023, 20:26:08) [Clang 14.0.6 ] (64-bit runtime)\r\nPython platform: macOS-13.2.1-arm64-arm-64bit\r\nIs CUDA available: False\r\nCUDA runtime version: No CUDA\r\nCUDA_MODULE_LOADING set to: N/A\r\nGPU models and configuration: No CUDA\r\nNvidia driver version: No CUDA\r\ncuDNN version: No CUDA\r\nHIP runtime version: N/A\r\nMIOpen runtime version: N/A\r\nIs XNNPACK available: True\r\n\r\nCPU:\r\nApple M1 Pro\r\n\r\nVersions of relevant libraries:\r\n[pip3] mypy-extensions==1.0.0\r\n[pip3] numpy==1.24.2\r\n[pip3] torch==2.0.0\r\n[pip3] torch-tb-profiler==0.4.1\r\n[pip3] torchvision==0.15.1\r\n[conda] numpy                     1.24.2          py310h3d2048e_0    conda-forge\r\n[conda] pytorch                   2.0.0                  py3.10_0    pytorch\r\n[conda] torch                     2.0.0                    pypi_0    pypi\r\n[conda] torch-tb-profiler         0.4.1                    pypi_0    pypi\r\n[conda] torchvision               0.15.1                   pypi_0    pypi\n\ncc @pmeier\nDataset MovingMNIST: `split=None` returns test dataset\n### \ud83d\udc1b Describe the bug\n\nI've found a bug in the code for torchvision's MovingMNIST dataset, which causes only the test dataset to be returned when split=None. According to the documentation, when split is set to None, the entire dataset should be returned. However, this is not currently happening.\r\nhttps://github.com/pytorch/vision/blob/b403bfc771e0caf31efd06d43860b09004f4ac61/torchvision/datasets/moving_mnist.py#L13-L19\r\n\r\nI've tested this with the following code:\r\n```python\r\nfrom torchvision import datasets\r\nimport torch\r\n\r\ndataset = datasets.MovingMNIST(root=\"data\", download=True)\r\ndataset[0].size() # returns torch.Size([10, 1, 64, 64]), but I expected torch.Size([20, 1, 64, 64])\r\n```\r\n\r\nI believe the bug is caused by lines 58-62 in the code, which handle None and test splits together:\r\nhttps://github.com/pytorch/vision/blob/b403bfc771e0caf31efd06d43860b09004f4ac61/torchvision/datasets/moving_mnist.py#L42-L62\r\n\r\nTo fix this, I propose the following two changes:\r\n- Separate the handling of None and test splits in the code.\r\n- Only process lines 46-50 when split is not None.\r\n\r\nReference issue: #6981 \r\n\r\nI'm happy to help on this issue, please assign to me on this one.\n\n### Versions\n\nPyTorch version: 2.0.0\r\nIs debug build: False\r\nCUDA used to build PyTorch: None\r\nROCM used to build PyTorch: N/A\r\n\r\nOS: macOS 13.2.1 (arm64)\r\nGCC version: Could not collect\r\nClang version: 14.0.0 (clang-1400.0.29.202)\r\nCMake version: Could not collect\r\nLibc version: N/A\r\n\r\nPython version: 3.10.9 | packaged by conda-forge | (main, Feb  2 2023, 20:26:08) [Clang 14.0.6 ] (64-bit runtime)\r\nPython platform: macOS-13.2.1-arm64-arm-64bit\r\nIs CUDA available: False\r\nCUDA runtime version: No CUDA\r\nCUDA_MODULE_LOADING set to: N/A\r\nGPU models and configuration: No CUDA\r\nNvidia driver version: No CUDA\r\ncuDNN version: No CUDA\r\nHIP runtime version: N/A\r\nMIOpen runtime version: N/A\r\nIs XNNPACK available: True\r\n\r\nCPU:\r\nApple M1 Pro\r\n\r\nVersions of relevant libraries:\r\n[pip3] mypy-extensions==1.0.0\r\n[pip3] numpy==1.24.2\r\n[pip3] torch==2.0.0\r\n[pip3] torch-tb-profiler==0.4.1\r\n[pip3] torchvision==0.15.1\r\n[conda] numpy                     1.24.2          py310h3d2048e_0    conda-forge\r\n[conda] pytorch                   2.0.0                  py3.10_0    pytorch\r\n[conda] torch                     2.0.0                    pypi_0    pypi\r\n[conda] torch-tb-profiler         0.4.1                    pypi_0    pypi\r\n[conda] torchvision               0.15.1                   pypi_0    pypi\n\ncc @pmeier\n", "before_files": [{"content": "import os.path\nfrom typing import Callable, Optional\n\nimport numpy as np\nimport torch\nfrom torchvision.datasets.utils import download_url, verify_str_arg\nfrom torchvision.datasets.vision import VisionDataset\n\n\nclass MovingMNIST(VisionDataset):\n    \"\"\"`MovingMNIST <http://www.cs.toronto.edu/~nitish/unsupervised_video/>`_ Dataset.\n\n    Args:\n        root (string): Root directory of dataset where ``MovingMNIST/mnist_test_seq.npy`` exists.\n        split (string, optional): The dataset split, supports ``None`` (default), ``\"train\"`` and ``\"test\"``.\n            If ``split=None``, the full data is returned.\n        split_ratio (int, optional): The split ratio of number of frames. If ``split=\"train\"``, the first split\n            frames ``data[:, :split_ratio]`` is returned. If ``split=\"test\"``, the last split frames ``data[:, split_ratio:]``\n            is returned. If ``split=None``, this parameter is ignored and the all frames data is returned.\n        transform (callable, optional): A function/transform that takes in an torch Tensor\n            and returns a transformed version. E.g, ``transforms.RandomCrop``\n        download (bool, optional): If true, downloads the dataset from the internet and\n            puts it in root directory. If dataset is already downloaded, it is not\n            downloaded again.\n    \"\"\"\n\n    _URL = \"http://www.cs.toronto.edu/~nitish/unsupervised_video/mnist_test_seq.npy\"\n\n    def __init__(\n        self,\n        root: str,\n        split: Optional[str] = None,\n        split_ratio: int = 10,\n        download: bool = False,\n        transform: Optional[Callable] = None,\n    ) -> None:\n        super().__init__(root, transform=transform)\n\n        self._base_folder = os.path.join(self.root, self.__class__.__name__)\n        self._filename = self._URL.split(\"/\")[-1]\n\n        if split is not None:\n            verify_str_arg(split, \"split\", (\"train\", \"test\"))\n        self.split = split\n\n        if not isinstance(split_ratio, int):\n            raise TypeError(f\"`split_ratio` should be an integer, but got {type(split_ratio)}\")\n        elif not (1 <= split_ratio <= 19):\n            raise ValueError(f\"`split_ratio` should be `1 <= split_ratio <= 19`, but got {split_ratio} instead.\")\n        self.split_ratio = split_ratio\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        data = torch.from_numpy(np.load(os.path.join(self._base_folder, self._filename)))\n        if self.split == \"train\":\n            data = data[: self.split_ratio]\n        else:\n            data = data[self.split_ratio :]\n        self.data = data.transpose(0, 1).unsqueeze(2).contiguous()\n\n    def __getitem__(self, idx: int) -> torch.Tensor:\n        \"\"\"\n        Args:\n            index (int): Index\n        Returns:\n            torch.Tensor: Video frames (torch Tensor[T, C, H, W]). The `T` is the number of frames.\n        \"\"\"\n        data = self.data[idx]\n        if self.transform is not None:\n            data = self.transform(data)\n\n        return data\n\n    def __len__(self) -> int:\n        return len(self.data)\n\n    def _check_exists(self) -> bool:\n        return os.path.exists(os.path.join(self._base_folder, self._filename))\n\n    def download(self) -> None:\n        if self._check_exists():\n            return\n\n        download_url(\n            url=self._URL,\n            root=self._base_folder,\n            filename=self._filename,\n            md5=\"be083ec986bfe91a449d63653c411eb2\",\n        )\n", "path": "torchvision/datasets/moving_mnist.py"}], "after_files": [{"content": "import os.path\nfrom typing import Callable, Optional\n\nimport numpy as np\nimport torch\nfrom torchvision.datasets.utils import download_url, verify_str_arg\nfrom torchvision.datasets.vision import VisionDataset\n\n\nclass MovingMNIST(VisionDataset):\n    \"\"\"`MovingMNIST <http://www.cs.toronto.edu/~nitish/unsupervised_video/>`_ Dataset.\n\n    Args:\n        root (string): Root directory of dataset where ``MovingMNIST/mnist_test_seq.npy`` exists.\n        split (string, optional): The dataset split, supports ``None`` (default), ``\"train\"`` and ``\"test\"``.\n            If ``split=None``, the full data is returned.\n        split_ratio (int, optional): The split ratio of number of frames. If ``split=\"train\"``, the first split\n            frames ``data[:, :split_ratio]`` is returned. If ``split=\"test\"``, the last split frames ``data[:, split_ratio:]``\n            is returned. If ``split=None``, this parameter is ignored and the all frames data is returned.\n        transform (callable, optional): A function/transform that takes in an torch Tensor\n            and returns a transformed version. E.g, ``transforms.RandomCrop``\n        download (bool, optional): If true, downloads the dataset from the internet and\n            puts it in root directory. If dataset is already downloaded, it is not\n            downloaded again.\n    \"\"\"\n\n    _URL = \"http://www.cs.toronto.edu/~nitish/unsupervised_video/mnist_test_seq.npy\"\n\n    def __init__(\n        self,\n        root: str,\n        split: Optional[str] = None,\n        split_ratio: int = 10,\n        download: bool = False,\n        transform: Optional[Callable] = None,\n    ) -> None:\n        super().__init__(root, transform=transform)\n\n        self._base_folder = os.path.join(self.root, self.__class__.__name__)\n        self._filename = self._URL.split(\"/\")[-1]\n\n        if split is not None:\n            verify_str_arg(split, \"split\", (\"train\", \"test\"))\n        self.split = split\n\n        if not isinstance(split_ratio, int):\n            raise TypeError(f\"`split_ratio` should be an integer, but got {type(split_ratio)}\")\n        elif not (1 <= split_ratio <= 19):\n            raise ValueError(f\"`split_ratio` should be `1 <= split_ratio <= 19`, but got {split_ratio} instead.\")\n        self.split_ratio = split_ratio\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        data = torch.from_numpy(np.load(os.path.join(self._base_folder, self._filename)))\n        if self.split == \"train\":\n            data = data[: self.split_ratio]\n        elif self.split == \"test\":\n            data = data[self.split_ratio :]\n        self.data = data.transpose(0, 1).unsqueeze(2).contiguous()\n\n    def __getitem__(self, idx: int) -> torch.Tensor:\n        \"\"\"\n        Args:\n            index (int): Index\n        Returns:\n            torch.Tensor: Video frames (torch Tensor[T, C, H, W]). The `T` is the number of frames.\n        \"\"\"\n        data = self.data[idx]\n        if self.transform is not None:\n            data = self.transform(data)\n\n        return data\n\n    def __len__(self) -> int:\n        return len(self.data)\n\n    def _check_exists(self) -> bool:\n        return os.path.exists(os.path.join(self._base_folder, self._filename))\n\n    def download(self) -> None:\n        if self._check_exists():\n            return\n\n        download_url(\n            url=self._URL,\n            root=self._base_folder,\n            filename=self._filename,\n            md5=\"be083ec986bfe91a449d63653c411eb2\",\n        )\n", "path": "torchvision/datasets/moving_mnist.py"}]}