prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  update documentation to reflect IMDB output
  When attempting to use the IMDB api, I got results that were different from what the docs suggested. This PR attempts to update the docs with the correct output of the IMDB api.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `torchtext/datasets/imdb.py`
  Content:
  ```
  1 import os
  2 from functools import partial
  3 from pathlib import Path
  4 from typing import Tuple, Union
  5 
  6 from torchtext._internal.module_utils import is_module_available
  7 from torchtext.data.datasets_utils import _create_dataset_directory
  8 from torchtext.data.datasets_utils import _wrap_split_argument
  9 
  10 if is_module_available("torchdata"):
  11     from torchdata.datapipes.iter import FileOpener, IterableWrapper
  12     from torchtext._download_hooks import HttpReader
  13 
  14 URL = "http://ai.stanford.edu/~amaas/data/sentiment/aclImdb_v1.tar.gz"
  15 
  16 MD5 = "7c2ac02c03563afcf9b574c7e56c153a"
  17 
  18 NUM_LINES = {
  19     "train": 25000,
  20     "test": 25000,
  21 }
  22 
  23 _PATH = "aclImdb_v1.tar.gz"
  24 
  25 DATASET_NAME = "IMDB"
  26 
  27 
  28 def _filepath_fn(root, _=None):
  29     return os.path.join(root, _PATH)
  30 
  31 
  32 def _decompressed_filepath_fn(root, decompressed_folder, split, labels, _=None):
  33     return [os.path.join(root, decompressed_folder, split, label) for label in labels]
  34 
  35 
  36 def _filter_fn(filter_imdb_data, split, t):
  37     return filter_imdb_data(split, t[0])
  38 
  39 
  40 def _path_map_fn(t):
  41     return Path(t[0]).parts[-2], t[1]
  42 
  43 
  44 def _encode_map_fn(x):
  45     return x[0], x[1].encode()
  46 
  47 
  48 def _cache_filepath_fn(root, decompressed_folder, split, x):
  49     return os.path.join(root, decompressed_folder, split, x)
  50 
  51 
  52 def _modify_res(t):
  53     return Path(t[0]).parts[-1], t[1]
  54 
  55 
  56 def filter_imdb_data(key, fname):
  57     labels = {"neg", "pos"}
  58     # eg. fname = "aclImdb/train/neg/12416_3.txt"
  59     *_, split, label, file = Path(fname).parts
  60     return key == split and label in labels
  61 
  62 
  63 @_create_dataset_directory(dataset_name=DATASET_NAME)
  64 @_wrap_split_argument(("train", "test"))
  65 def IMDB(root: str, split: Union[Tuple[str], str]):
  66     """IMDB Dataset
  67 
  68     .. warning::
  69 
  70         using datapipes is still currently subject to a few caveats. if you wish
  71         to use this dataset with shuffling, multi-processing, or distributed
  72         learning, please see :ref:`this note <datapipes_warnings>` for further
  73         instructions.
  74 
  75     For additional details refer to http://ai.stanford.edu/~amaas/data/sentiment/
  76 
  77     Number of lines per split:
  78         - train: 25000
  79         - test: 25000
  80 
  81     Args:
  82         root: Directory where the datasets are saved. Default: os.path.expanduser('~/.torchtext/cache')
  83         split: split or splits to be returned. Can be a string or tuple of strings. Default: (`train`, `test`)
  84 
  85     :returns: DataPipe that yields tuple of label (1 to 2) and text containing the movie review
  86     :rtype: (int, str)
  87     """
  88     if not is_module_available("torchdata"):
  89         raise ModuleNotFoundError(
  90             "Package `torchdata` not found. Please install following instructions at https://github.com/pytorch/data"
  91         )
  92 
  93     url_dp = IterableWrapper([URL])
  94 
  95     cache_compressed_dp = url_dp.on_disk_cache(
  96         filepath_fn=partial(_filepath_fn, root),
  97         hash_dict={_filepath_fn(root): MD5},
  98         hash_type="md5",
  99     )
  100     cache_compressed_dp = HttpReader(cache_compressed_dp).end_caching(mode="wb", same_filepath_fn=True)
  101 
  102     labels = {"neg", "pos"}
  103     decompressed_folder = "aclImdb_v1"
  104     cache_decompressed_dp = cache_compressed_dp.on_disk_cache(
  105         filepath_fn=partial(_decompressed_filepath_fn, root, decompressed_folder, split, labels)
  106     )
  107     cache_decompressed_dp = FileOpener(cache_decompressed_dp, mode="b")
  108     cache_decompressed_dp = cache_decompressed_dp.load_from_tar()
  109     cache_decompressed_dp = cache_decompressed_dp.filter(partial(_filter_fn, filter_imdb_data, split))
  110 
  111     # eg. "aclImdb/train/neg/12416_3.txt" -> "neg"
  112     cache_decompressed_dp = cache_decompressed_dp.map(_path_map_fn)
  113     cache_decompressed_dp = cache_decompressed_dp.readlines(decode=True)
  114     cache_decompressed_dp = cache_decompressed_dp.lines_to_paragraphs()  # group by label in cache file
  115     cache_decompressed_dp = cache_decompressed_dp.map(_encode_map_fn)
  116     cache_decompressed_dp = cache_decompressed_dp.end_caching(
  117         mode="wb", filepath_fn=partial(_cache_filepath_fn, root, decompressed_folder, split), skip_read=True
  118     )
  119 
  120     data_dp = FileOpener(cache_decompressed_dp, encoding="utf-8")
  121     # get label from cache file, eg. "aclImdb_v1/train/neg" -> "neg"
  122     return data_dp.readlines().map(_modify_res).shuffle().set_shuffle(False).sharding_filter()
  123
  ```
  --- 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()
  
  ```
  
golden_diff: diff --git a/torchtext/datasets/imdb.py b/torchtext/datasets/imdb.py
  --- a/torchtext/datasets/imdb.py
  +++ b/torchtext/datasets/imdb.py
  @@ -20,6 +20,8 @@
       "test": 25000,
   }
   
  +MAP_LABELS = {"neg": 1, "pos": 2}
  +
   _PATH = "aclImdb_v1.tar.gz"
   
   DATASET_NAME = "IMDB"
  @@ -50,7 +52,7 @@
   
   
   def _modify_res(t):
  -    return Path(t[0]).parts[-1], t[1]
  +    return MAP_LABELS[Path(t[0]).parts[-1]], t[1]
   
   
   def filter_imdb_data(key, fname):
  
verification_info: {"golden_diff": "diff --git a/torchtext/datasets/imdb.py b/torchtext/datasets/imdb.py\n--- a/torchtext/datasets/imdb.py\n+++ b/torchtext/datasets/imdb.py\n@@ -20,6 +20,8 @@\n     \"test\": 25000,\n }\n \n+MAP_LABELS = {\"neg\": 1, \"pos\": 2}\n+\n _PATH = \"aclImdb_v1.tar.gz\"\n \n DATASET_NAME = \"IMDB\"\n@@ -50,7 +52,7 @@\n \n \n def _modify_res(t):\n-    return Path(t[0]).parts[-1], t[1]\n+    return MAP_LABELS[Path(t[0]).parts[-1]], t[1]\n \n \n def filter_imdb_data(key, fname):\n", "issue": "update documentation to reflect IMDB output\nWhen attempting to use the IMDB api, I got results that were different from what the docs suggested. This PR attempts to update the docs with the correct output of the IMDB api.\n", "before_files": [{"content": "import os\nfrom functools import partial\nfrom pathlib import Path\nfrom typing import Tuple, Union\n\nfrom torchtext._internal.module_utils import is_module_available\nfrom torchtext.data.datasets_utils import _create_dataset_directory\nfrom torchtext.data.datasets_utils import _wrap_split_argument\n\nif is_module_available(\"torchdata\"):\n    from torchdata.datapipes.iter import FileOpener, IterableWrapper\n    from torchtext._download_hooks import HttpReader\n\nURL = \"http://ai.stanford.edu/~amaas/data/sentiment/aclImdb_v1.tar.gz\"\n\nMD5 = \"7c2ac02c03563afcf9b574c7e56c153a\"\n\nNUM_LINES = {\n    \"train\": 25000,\n    \"test\": 25000,\n}\n\n_PATH = \"aclImdb_v1.tar.gz\"\n\nDATASET_NAME = \"IMDB\"\n\n\ndef _filepath_fn(root, _=None):\n    return os.path.join(root, _PATH)\n\n\ndef _decompressed_filepath_fn(root, decompressed_folder, split, labels, _=None):\n    return [os.path.join(root, decompressed_folder, split, label) for label in labels]\n\n\ndef _filter_fn(filter_imdb_data, split, t):\n    return filter_imdb_data(split, t[0])\n\n\ndef _path_map_fn(t):\n    return Path(t[0]).parts[-2], t[1]\n\n\ndef _encode_map_fn(x):\n    return x[0], x[1].encode()\n\n\ndef _cache_filepath_fn(root, decompressed_folder, split, x):\n    return os.path.join(root, decompressed_folder, split, x)\n\n\ndef _modify_res(t):\n    return Path(t[0]).parts[-1], t[1]\n\n\ndef filter_imdb_data(key, fname):\n    labels = {\"neg\", \"pos\"}\n    # eg. fname = \"aclImdb/train/neg/12416_3.txt\"\n    *_, split, label, file = Path(fname).parts\n    return key == split and label in labels\n\n\n@_create_dataset_directory(dataset_name=DATASET_NAME)\n@_wrap_split_argument((\"train\", \"test\"))\ndef IMDB(root: str, split: Union[Tuple[str], str]):\n    \"\"\"IMDB Dataset\n\n    .. warning::\n\n        using datapipes is still currently subject to a few caveats. if you wish\n        to use this dataset with shuffling, multi-processing, or distributed\n        learning, please see :ref:`this note <datapipes_warnings>` for further\n        instructions.\n\n    For additional details refer to http://ai.stanford.edu/~amaas/data/sentiment/\n\n    Number of lines per split:\n        - train: 25000\n        - test: 25000\n\n    Args:\n        root: Directory where the datasets are saved. Default: os.path.expanduser('~/.torchtext/cache')\n        split: split or splits to be returned. Can be a string or tuple of strings. Default: (`train`, `test`)\n\n    :returns: DataPipe that yields tuple of label (1 to 2) and text containing the movie review\n    :rtype: (int, str)\n    \"\"\"\n    if not is_module_available(\"torchdata\"):\n        raise ModuleNotFoundError(\n            \"Package `torchdata` not found. Please install following instructions at https://github.com/pytorch/data\"\n        )\n\n    url_dp = IterableWrapper([URL])\n\n    cache_compressed_dp = url_dp.on_disk_cache(\n        filepath_fn=partial(_filepath_fn, root),\n        hash_dict={_filepath_fn(root): MD5},\n        hash_type=\"md5\",\n    )\n    cache_compressed_dp = HttpReader(cache_compressed_dp).end_caching(mode=\"wb\", same_filepath_fn=True)\n\n    labels = {\"neg\", \"pos\"}\n    decompressed_folder = \"aclImdb_v1\"\n    cache_decompressed_dp = cache_compressed_dp.on_disk_cache(\n        filepath_fn=partial(_decompressed_filepath_fn, root, decompressed_folder, split, labels)\n    )\n    cache_decompressed_dp = FileOpener(cache_decompressed_dp, mode=\"b\")\n    cache_decompressed_dp = cache_decompressed_dp.load_from_tar()\n    cache_decompressed_dp = cache_decompressed_dp.filter(partial(_filter_fn, filter_imdb_data, split))\n\n    # eg. \"aclImdb/train/neg/12416_3.txt\" -> \"neg\"\n    cache_decompressed_dp = cache_decompressed_dp.map(_path_map_fn)\n    cache_decompressed_dp = cache_decompressed_dp.readlines(decode=True)\n    cache_decompressed_dp = cache_decompressed_dp.lines_to_paragraphs()  # group by label in cache file\n    cache_decompressed_dp = cache_decompressed_dp.map(_encode_map_fn)\n    cache_decompressed_dp = cache_decompressed_dp.end_caching(\n        mode=\"wb\", filepath_fn=partial(_cache_filepath_fn, root, decompressed_folder, split), skip_read=True\n    )\n\n    data_dp = FileOpener(cache_decompressed_dp, encoding=\"utf-8\")\n    # get label from cache file, eg. \"aclImdb_v1/train/neg\" -> \"neg\"\n    return data_dp.readlines().map(_modify_res).shuffle().set_shuffle(False).sharding_filter()\n", "path": "torchtext/datasets/imdb.py"}], "after_files": [{"content": "import os\nfrom functools import partial\nfrom pathlib import Path\nfrom typing import Tuple, Union\n\nfrom torchtext._internal.module_utils import is_module_available\nfrom torchtext.data.datasets_utils import _create_dataset_directory\nfrom torchtext.data.datasets_utils import _wrap_split_argument\n\nif is_module_available(\"torchdata\"):\n    from torchdata.datapipes.iter import FileOpener, IterableWrapper\n    from torchtext._download_hooks import HttpReader\n\nURL = \"http://ai.stanford.edu/~amaas/data/sentiment/aclImdb_v1.tar.gz\"\n\nMD5 = \"7c2ac02c03563afcf9b574c7e56c153a\"\n\nNUM_LINES = {\n    \"train\": 25000,\n    \"test\": 25000,\n}\n\nMAP_LABELS = {\"neg\": 1, \"pos\": 2}\n\n_PATH = \"aclImdb_v1.tar.gz\"\n\nDATASET_NAME = \"IMDB\"\n\n\ndef _filepath_fn(root, _=None):\n    return os.path.join(root, _PATH)\n\n\ndef _decompressed_filepath_fn(root, decompressed_folder, split, labels, _=None):\n    return [os.path.join(root, decompressed_folder, split, label) for label in labels]\n\n\ndef _filter_fn(filter_imdb_data, split, t):\n    return filter_imdb_data(split, t[0])\n\n\ndef _path_map_fn(t):\n    return Path(t[0]).parts[-2], t[1]\n\n\ndef _encode_map_fn(x):\n    return x[0], x[1].encode()\n\n\ndef _cache_filepath_fn(root, decompressed_folder, split, x):\n    return os.path.join(root, decompressed_folder, split, x)\n\n\ndef _modify_res(t):\n    return MAP_LABELS[Path(t[0]).parts[-1]], t[1]\n\n\ndef filter_imdb_data(key, fname):\n    labels = {\"neg\", \"pos\"}\n    # eg. fname = \"aclImdb/train/neg/12416_3.txt\"\n    *_, split, label, file = Path(fname).parts\n    return key == split and label in labels\n\n\n@_create_dataset_directory(dataset_name=DATASET_NAME)\n@_wrap_split_argument((\"train\", \"test\"))\ndef IMDB(root: str, split: Union[Tuple[str], str]):\n    \"\"\"IMDB Dataset\n\n    .. warning::\n\n        using datapipes is still currently subject to a few caveats. if you wish\n        to use this dataset with shuffling, multi-processing, or distributed\n        learning, please see :ref:`this note <datapipes_warnings>` for further\n        instructions.\n\n    For additional details refer to http://ai.stanford.edu/~amaas/data/sentiment/\n\n    Number of lines per split:\n        - train: 25000\n        - test: 25000\n\n    Args:\n        root: Directory where the datasets are saved. Default: os.path.expanduser('~/.torchtext/cache')\n        split: split or splits to be returned. Can be a string or tuple of strings. Default: (`train`, `test`)\n\n    :returns: DataPipe that yields tuple of label (1 to 2) and text containing the movie review\n    :rtype: (int, str)\n    \"\"\"\n    if not is_module_available(\"torchdata\"):\n        raise ModuleNotFoundError(\n            \"Package `torchdata` not found. Please install following instructions at https://github.com/pytorch/data\"\n        )\n\n    url_dp = IterableWrapper([URL])\n\n    cache_compressed_dp = url_dp.on_disk_cache(\n        filepath_fn=partial(_filepath_fn, root),\n        hash_dict={_filepath_fn(root): MD5},\n        hash_type=\"md5\",\n    )\n    cache_compressed_dp = HttpReader(cache_compressed_dp).end_caching(mode=\"wb\", same_filepath_fn=True)\n\n    labels = {\"neg\", \"pos\"}\n    decompressed_folder = \"aclImdb_v1\"\n    cache_decompressed_dp = cache_compressed_dp.on_disk_cache(\n        filepath_fn=partial(_decompressed_filepath_fn, root, decompressed_folder, split, labels)\n    )\n    cache_decompressed_dp = FileOpener(cache_decompressed_dp, mode=\"b\")\n    cache_decompressed_dp = cache_decompressed_dp.load_from_tar()\n    cache_decompressed_dp = cache_decompressed_dp.filter(partial(_filter_fn, filter_imdb_data, split))\n\n    # eg. \"aclImdb/train/neg/12416_3.txt\" -> \"neg\"\n    cache_decompressed_dp = cache_decompressed_dp.map(_path_map_fn)\n    cache_decompressed_dp = cache_decompressed_dp.readlines(decode=True)\n    cache_decompressed_dp = cache_decompressed_dp.lines_to_paragraphs()  # group by label in cache file\n    cache_decompressed_dp = cache_decompressed_dp.map(_encode_map_fn)\n    cache_decompressed_dp = cache_decompressed_dp.end_caching(\n        mode=\"wb\", filepath_fn=partial(_cache_filepath_fn, root, decompressed_folder, split), skip_read=True\n    )\n\n    data_dp = FileOpener(cache_decompressed_dp, encoding=\"utf-8\")\n    # get label from cache file, eg. \"aclImdb_v1/train/neg\" -> \"neg\"\n    return data_dp.readlines().map(_modify_res).shuffle().set_shuffle(False).sharding_filter()\n", "path": "torchtext/datasets/imdb.py"}]}