We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Pyright version pinning not working
It appears that pyright versioning is still not working when using `pip install pyright`. We should switch to using the node version, which respects versioning.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `setup.py`
Content:
```
1 # Copyright 2021 MosaicML. All Rights Reserved.
2 
3 import os
4 import site
5 import sys
6 import textwrap
7 
8 import setuptools
9 from setuptools import setup
10 from setuptools.command.develop import develop as develop_orig
11 
12 _IS_ROOT = os.getuid() == 0
13 _IS_USER = "--user" in sys.argv[1:]
14 _IS_VIRTUALENV = "VIRTUAL_ENV" in os.environ
15 
16 
17 # From https://stackoverflow.com/questions/51292333/how-to-tell-from-setup-py-if-the-module-is-being-installed-in-editable-mode
18 class develop(develop_orig):
19 
20     def run(self):
21         if _IS_ROOT and (not _IS_VIRTUALENV) and (not _IS_USER):
22             raise RuntimeError(
23                 textwrap.dedent("""\
24                     When installing in editable mode as root outside of a virtual environment,
25                     please specify `--user`. Editable installs as the root user outside of a virtual environment
26                     do not work without the `--user` flag. Please instead run something like: `pip install --user -e .`"""
27                                ))
28         super().run()
29 
30 
31 # From https://github.com/pypa/pip/issues/7953#issuecomment-645133255
32 site.ENABLE_USER_SITE = _IS_USER
33 
34 
35 def package_files(directory: str):
36     # from https://stackoverflow.com/a/36693250
37     paths = []
38     for (path, _, filenames) in os.walk(directory):
39         for filename in filenames:
40             paths.append(os.path.join('..', path, filename))
41     return paths
42 
43 
44 with open("README.md", "r", encoding="utf-8") as fh:
45     long_description = fh.read()
46 
47 install_requires = [
48     "pyyaml>=5.4.1",
49     "tqdm>=4.62.3",
50     "torchmetrics>=0.6.0",
51     "torch_optimizer==0.1.0",
52     "torchvision>=0.9.0",
53     "torch>=1.9",
54     "yahp>=0.1.0",
55     "requests>=2.26.0",
56     "numpy==1.21.5",
57     "apache-libcloud>=3.3.1",
58     "psutil>=5.8.0",
59 ]
60 extra_deps = {}
61 
62 extra_deps['base'] = []
63 
64 extra_deps['dev'] = [
65     # Imports for docs builds and running tests
66     "custom_inherit==2.3.2",
67     'junitparser>=2.1.1',
68     'coverage[toml]>=6.1.1',
69     'fasteners==0.17.3',  # run_directory_uploader tests require fasteners
70     'pytest>=7.0.0',
71     'toml==0.10.2',
72     'yapf==0.32.0',
73     'isort>=5.9.3',
74     'ipython>=7.29.0',
75     'ipykernel>=6.5.0',
76     'jupyter>=1.0.0',
77     'yamllint>=1.26.2',
78     'pytest-timeout>=1.4.2',
79     'pyright==1.1.224.post1',
80     'recommonmark==0.7.1',
81     'sphinx>=4.4.0',
82     'docutils>=0.15',
83     'sphinx_copybutton==0.5.0',
84     'sphinx_markdown_tables==0.0.15',
85     'sphinx-argparse==0.3.1',
86     'sphinxcontrib.katex==0.8.6',
87     'sphinxext.opengraph==0.6.1',
88     'sphinxemoji==0.2.0',
89     'furo>=2022.1.2',
90     'sphinx-copybutton==0.5.0',
91     'testbook==0.4.2',
92     'myst-parser==0.16.1',
93     'pylint>=2.12.2',
94     'docformatter>=1.4',
95     'sphinx_panels==0.6.0',
96     'sphinxcontrib-images==0.9.4',
97 ]
98 
99 extra_deps["deepspeed"] = [
100     'deepspeed==0.5.10',
101 ]
102 
103 extra_deps["wandb"] = [
104     'wandb==0.12.10',
105     'coolname>=1.1.0',
106 ]
107 
108 extra_deps["unet"] = [
109     'monai==0.8.1',
110     'scikit-learn>=1.0.1',
111 ]
112 
113 extra_deps["vit"] = [
114     'vit_pytorch>=0.27',
115 ]
116 
117 extra_deps["timm"] = [
118     'timm==0.5.4',
119 ]
120 
121 extra_deps["coco"] = [
122     'pycocotools>=2.0.4',
123 ]
124 
125 extra_deps["nlp"] = [
126     'transformers>=4.11',
127     'datasets>=1.14',
128 ]
129 
130 extra_deps['webdataset'] = [
131     'awscli>=1.22.60',
132     'webdataset @ git+https://github.com/mosaicml/webdataset.git@dev',
133     'wurlitzer>=3.0.2',
134 ]
135 
136 extra_deps['all'] = set(dep for deps in extra_deps.values() for dep in deps)
137 
138 setup(name="mosaicml",
139       version="0.4.0",
140       author="MosaicML",
141       author_email="team@mosaicml.com",
142       description="Composer provides well-engineered implementations of efficient training methods to give "
143       "the tools that help you train a better model for cheaper.",
144       long_description=long_description,
145       long_description_content_type="text/markdown",
146       url="https://github.com/mosaicml/composer",
147       include_package_data=True,
148       package_data={
149           "composer": ['py.typed'],
150           "": package_files('composer/yamls'),
151           "": package_files('composer/algorithms')
152       },
153       packages=setuptools.find_packages(exclude=["tests*"]),
154       classifiers=[
155           "Programming Language :: Python :: 3",
156           "Programming Language :: Python :: 3.7",
157           "Programming Language :: Python :: 3.8",
158           "Programming Language :: Python :: 3.9",
159       ],
160       install_requires=install_requires,
161       entry_points={
162           'console_scripts': ['composer = composer.cli.launcher:main',],
163       },
164       extras_require=extra_deps,
165       dependency_links=['https://developer.download.nvidia.com/compute/redist'],
166       python_requires='>=3.7',
167       ext_package="composer",
168       cmdclass={'develop': develop})
169 
170 # only visible if user installs with verbose -v flag
171 # Printing to stdout as not to interfere with setup.py CLI flags (e.g. --version)
172 print("*" * 20, file=sys.stderr)
173 print(textwrap.dedent("""\
174     NOTE: For best performance, we recommend installing Pillow-SIMD
175     for accelerated image processing operations. To install:
176     \t pip uninstall pillow && pip install pillow-simd"""),
177       file=sys.stderr)
178 print("*" * 20, file=sys.stderr)
179
```

Path: `docs/source/doctest_fixtures.py`
Content:
```
1 # Copyright 2021 MosaicML. All Rights Reserved.
2 
3 """
4 Fixtures available in doctests.
5 
6 The script is run before any doctests are executed,
7 so all imports and variables are available in any doctest.
8 The output of this setup script does not show up in the documentation.
9 """
10 import functools
11 import os
12 import sys
13 from typing import Callable
14 
15 import numpy as np
16 import torch.optim
17 import torch.utils.data
18 from PIL import Image
19 from torch.optim.lr_scheduler import CosineAnnealingLR
20 
21 import composer
22 from composer import Trainer as OriginalTrainer
23 from composer import *  # Make all composer imports available in doctests
24 from composer.core.logging import LogLevel
25 from composer.core.time import Time, Timestamp
26 from composer.datasets.synthetic import SyntheticBatchPairDataset
27 from composer.loggers import InMemoryLogger
28 from composer.utils import *  # Make all composer.utils imports available in doctests
29 
30 # Need to insert the repo root at the beginning of the path, since there may be other modules named `tests`
31 # Assuming that docs generation is running from the `docs` directory
32 _docs_dir = os.path.abspath(".")
33 _repo_root = os.path.dirname(_docs_dir)
34 if sys.path[0] != _repo_root:
35     sys.path.insert(0, _repo_root)
36 
37 from tests.fixtures.models import SimpleBatchPairModel
38 
39 num_channels = 3
40 num_classes = 10
41 data_shape = (num_channels, 5, 5)
42 
43 model = SimpleBatchPairModel(num_channels, num_classes)
44 
45 optimizer = torch.optim.SGD(model.parameters(), lr=0.001)
46 
47 scheduler = CosineAnnealingLR(optimizer, T_max=1)
48 
49 dataset = SyntheticBatchPairDataset(
50     total_dataset_size=100,
51     data_shape=data_shape,
52     num_classes=num_classes,
53     num_unique_samples_to_create=10,
54 )
55 
56 train_dataset = dataset
57 eval_dataset = dataset
58 
59 batch_size = 10
60 
61 train_dataloader = torch.utils.data.DataLoader(
62     train_dataset,
63     batch_size=batch_size,
64     num_workers=0,
65     pin_memory=False,
66     drop_last=True,
67 )
68 
69 eval_dataloader = torch.utils.data.DataLoader(
70     eval_dataset,
71     batch_size=batch_size,
72     num_workers=0,
73     pin_memory=False,
74     drop_last=False,
75 )
76 
77 state = State(
78     rank_zero_seed=0,
79     model=model,
80     optimizers=optimizer,
81     grad_accum=1,
82     train_dataloader=train_dataloader,
83     evaluators=[],
84     max_duration="1ep",
85     precision="fp32",
86 )
87 
88 logger = Logger(state)
89 
90 engine = Engine(state, logger)
91 
92 image = Image.fromarray(np.random.randint(0, 256, size=(32, 32, 3), dtype=np.uint8))
93 
94 # error: "randn" is not a known member of module (reportGeneralTypeIssues)
95 X_example = torch.randn(batch_size, num_channels, 32, 32)  # type: ignore
96 # error: "randn" is not a known member of module (reportGeneralTypeIssues)
97 logits = torch.randn(batch_size, num_classes)  # type: ignore
98 # error: "randint" is not a known member of module (reportGeneralTypeIssues)
99 y_example = torch.randint(num_classes, (batch_size,))  # type: ignore
100 
101 
102 # patch the Trainer to accept ellipses
103 def Trainer(fake_ellipses='...', *args, **kwargs):
104     return OriginalTrainer(*args, **kwargs)
105 
106 
107 # bind the required arguments to the Trainer so it can be used without arguments in the doctests
108 Trainer = functools.partial(
109     Trainer,
110     model=model,
111     max_duration="1ep",
112     train_dataloader=train_dataloader,
113     eval_dataloader=eval_dataloader,
114 )
115 
116 # patch composer so that 'from composer import Trainer' calls do not override change above
117 composer.Trainer = Trainer
118
```
--- 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/docs/source/doctest_fixtures.py b/docs/source/doctest_fixtures.py
--- a/docs/source/doctest_fixtures.py
+++ b/docs/source/doctest_fixtures.py
@@ -10,7 +10,7 @@
 import functools
 import os
 import sys
-from typing import Callable
+from typing import Callable as Callable
 
 import numpy as np
 import torch.optim
@@ -21,10 +21,10 @@
 import composer
 from composer import Trainer as OriginalTrainer
 from composer import *  # Make all composer imports available in doctests
-from composer.core.logging import LogLevel
-from composer.core.time import Time, Timestamp
+from composer.core.logging import LogLevel as LogLevel
+from composer.core.time import Time as Time, Timestamp as Timestamp
 from composer.datasets.synthetic import SyntheticBatchPairDataset
-from composer.loggers import InMemoryLogger
+from composer.loggers import InMemoryLogger as InMemoryLogger
 from composer.utils import *  # Make all composer.utils imports available in doctests
 
 # Need to insert the repo root at the beginning of the path, since there may be other modules named `tests`
@@ -105,7 +105,9 @@
 
 
 # bind the required arguments to the Trainer so it can be used without arguments in the doctests
-Trainer = functools.partial(
+
+# Declaration "Trainer" is obscured by a declaration of the same name (reportGeneralTypeIssues)
+Trainer = functools.partial(  # type: ignore
     Trainer,
     model=model,
     max_duration="1ep",
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -76,7 +76,6 @@
     'jupyter>=1.0.0',
     'yamllint>=1.26.2',
     'pytest-timeout>=1.4.2',
-    'pyright==1.1.224.post1',
     'recommonmark==0.7.1',
     'sphinx>=4.4.0',
     'docutils>=0.15',

{"golden_diff": "diff --git a/docs/source/doctest_fixtures.py b/docs/source/doctest_fixtures.py\n--- a/docs/source/doctest_fixtures.py\n+++ b/docs/source/doctest_fixtures.py\n@@ -10,7 +10,7 @@\n import functools\n import os\n import sys\n-from typing import Callable\n+from typing import Callable as Callable\n \n import numpy as np\n import torch.optim\n@@ -21,10 +21,10 @@\n import composer\n from composer import Trainer as OriginalTrainer\n from composer import *  # Make all composer imports available in doctests\n-from composer.core.logging import LogLevel\n-from composer.core.time import Time, Timestamp\n+from composer.core.logging import LogLevel as LogLevel\n+from composer.core.time import Time as Time, Timestamp as Timestamp\n from composer.datasets.synthetic import SyntheticBatchPairDataset\n-from composer.loggers import InMemoryLogger\n+from composer.loggers import InMemoryLogger as InMemoryLogger\n from composer.utils import *  # Make all composer.utils imports available in doctests\n \n # Need to insert the repo root at the beginning of the path, since there may be other modules named `tests`\n@@ -105,7 +105,9 @@\n \n \n # bind the required arguments to the Trainer so it can be used without arguments in the doctests\n-Trainer = functools.partial(\n+\n+# Declaration \"Trainer\" is obscured by a declaration of the same name (reportGeneralTypeIssues)\n+Trainer = functools.partial(  # type: ignore\n     Trainer,\n     model=model,\n     max_duration=\"1ep\",\ndiff --git a/setup.py b/setup.py\n--- a/setup.py\n+++ b/setup.py\n@@ -76,7 +76,6 @@\n     'jupyter>=1.0.0',\n     'yamllint>=1.26.2',\n     'pytest-timeout>=1.4.2',\n-    'pyright==1.1.224.post1',\n     'recommonmark==0.7.1',\n     'sphinx>=4.4.0',\n     'docutils>=0.15',\n", "issue": "Pyright version pinning not working\nIt appears that pyright versioning is still not working when using `pip install pyright`. We should switch to using the node version, which respects versioning.\n", "before_files": [{"content": "# Copyright 2021 MosaicML. All Rights Reserved.\n\nimport os\nimport site\nimport sys\nimport textwrap\n\nimport setuptools\nfrom setuptools import setup\nfrom setuptools.command.develop import develop as develop_orig\n\n_IS_ROOT = os.getuid() == 0\n_IS_USER = \"--user\" in sys.argv[1:]\n_IS_VIRTUALENV = \"VIRTUAL_ENV\" in os.environ\n\n\n# From https://stackoverflow.com/questions/51292333/how-to-tell-from-setup-py-if-the-module-is-being-installed-in-editable-mode\nclass develop(develop_orig):\n\n    def run(self):\n        if _IS_ROOT and (not _IS_VIRTUALENV) and (not _IS_USER):\n            raise RuntimeError(\n                textwrap.dedent(\"\"\"\\\n                    When installing in editable mode as root outside of a virtual environment,\n                    please specify `--user`. Editable installs as the root user outside of a virtual environment\n                    do not work without the `--user` flag. Please instead run something like: `pip install --user -e .`\"\"\"\n                               ))\n        super().run()\n\n\n# From https://github.com/pypa/pip/issues/7953#issuecomment-645133255\nsite.ENABLE_USER_SITE = _IS_USER\n\n\ndef package_files(directory: str):\n    # from https://stackoverflow.com/a/36693250\n    paths = []\n    for (path, _, filenames) in os.walk(directory):\n        for filename in filenames:\n            paths.append(os.path.join('..', path, filename))\n    return paths\n\n\nwith open(\"README.md\", \"r\", encoding=\"utf-8\") as fh:\n    long_description = fh.read()\n\ninstall_requires = [\n    \"pyyaml>=5.4.1\",\n    \"tqdm>=4.62.3\",\n    \"torchmetrics>=0.6.0\",\n    \"torch_optimizer==0.1.0\",\n    \"torchvision>=0.9.0\",\n    \"torch>=1.9\",\n    \"yahp>=0.1.0\",\n    \"requests>=2.26.0\",\n    \"numpy==1.21.5\",\n    \"apache-libcloud>=3.3.1\",\n    \"psutil>=5.8.0\",\n]\nextra_deps = {}\n\nextra_deps['base'] = []\n\nextra_deps['dev'] = [\n    # Imports for docs builds and running tests\n    \"custom_inherit==2.3.2\",\n    'junitparser>=2.1.1',\n    'coverage[toml]>=6.1.1',\n    'fasteners==0.17.3',  # run_directory_uploader tests require fasteners\n    'pytest>=7.0.0',\n    'toml==0.10.2',\n    'yapf==0.32.0',\n    'isort>=5.9.3',\n    'ipython>=7.29.0',\n    'ipykernel>=6.5.0',\n    'jupyter>=1.0.0',\n    'yamllint>=1.26.2',\n    'pytest-timeout>=1.4.2',\n    'pyright==1.1.224.post1',\n    'recommonmark==0.7.1',\n    'sphinx>=4.4.0',\n    'docutils>=0.15',\n    'sphinx_copybutton==0.5.0',\n    'sphinx_markdown_tables==0.0.15',\n    'sphinx-argparse==0.3.1',\n    'sphinxcontrib.katex==0.8.6',\n    'sphinxext.opengraph==0.6.1',\n    'sphinxemoji==0.2.0',\n    'furo>=2022.1.2',\n    'sphinx-copybutton==0.5.0',\n    'testbook==0.4.2',\n    'myst-parser==0.16.1',\n    'pylint>=2.12.2',\n    'docformatter>=1.4',\n    'sphinx_panels==0.6.0',\n    'sphinxcontrib-images==0.9.4',\n]\n\nextra_deps[\"deepspeed\"] = [\n    'deepspeed==0.5.10',\n]\n\nextra_deps[\"wandb\"] = [\n    'wandb==0.12.10',\n    'coolname>=1.1.0',\n]\n\nextra_deps[\"unet\"] = [\n    'monai==0.8.1',\n    'scikit-learn>=1.0.1',\n]\n\nextra_deps[\"vit\"] = [\n    'vit_pytorch>=0.27',\n]\n\nextra_deps[\"timm\"] = [\n    'timm==0.5.4',\n]\n\nextra_deps[\"coco\"] = [\n    'pycocotools>=2.0.4',\n]\n\nextra_deps[\"nlp\"] = [\n    'transformers>=4.11',\n    'datasets>=1.14',\n]\n\nextra_deps['webdataset'] = [\n    'awscli>=1.22.60',\n    'webdataset @ git+https://github.com/mosaicml/webdataset.git@dev',\n    'wurlitzer>=3.0.2',\n]\n\nextra_deps['all'] = set(dep for deps in extra_deps.values() for dep in deps)\n\nsetup(name=\"mosaicml\",\n      version=\"0.4.0\",\n      author=\"MosaicML\",\n      author_email=\"team@mosaicml.com\",\n      description=\"Composer provides well-engineered implementations of efficient training methods to give \"\n      \"the tools that help you train a better model for cheaper.\",\n      long_description=long_description,\n      long_description_content_type=\"text/markdown\",\n      url=\"https://github.com/mosaicml/composer\",\n      include_package_data=True,\n      package_data={\n          \"composer\": ['py.typed'],\n          \"\": package_files('composer/yamls'),\n          \"\": package_files('composer/algorithms')\n      },\n      packages=setuptools.find_packages(exclude=[\"tests*\"]),\n      classifiers=[\n          \"Programming Language :: Python :: 3\",\n          \"Programming Language :: Python :: 3.7\",\n          \"Programming Language :: Python :: 3.8\",\n          \"Programming Language :: Python :: 3.9\",\n      ],\n      install_requires=install_requires,\n      entry_points={\n          'console_scripts': ['composer = composer.cli.launcher:main',],\n      },\n      extras_require=extra_deps,\n      dependency_links=['https://developer.download.nvidia.com/compute/redist'],\n      python_requires='>=3.7',\n      ext_package=\"composer\",\n      cmdclass={'develop': develop})\n\n# only visible if user installs with verbose -v flag\n# Printing to stdout as not to interfere with setup.py CLI flags (e.g. --version)\nprint(\"*\" * 20, file=sys.stderr)\nprint(textwrap.dedent(\"\"\"\\\n    NOTE: For best performance, we recommend installing Pillow-SIMD\n    for accelerated image processing operations. To install:\n    \\t pip uninstall pillow && pip install pillow-simd\"\"\"),\n      file=sys.stderr)\nprint(\"*\" * 20, file=sys.stderr)\n", "path": "setup.py"}, {"content": "# Copyright 2021 MosaicML. All Rights Reserved.\n\n\"\"\"\nFixtures available in doctests.\n\nThe script is run before any doctests are executed,\nso all imports and variables are available in any doctest.\nThe output of this setup script does not show up in the documentation.\n\"\"\"\nimport functools\nimport os\nimport sys\nfrom typing import Callable\n\nimport numpy as np\nimport torch.optim\nimport torch.utils.data\nfrom PIL import Image\nfrom torch.optim.lr_scheduler import CosineAnnealingLR\n\nimport composer\nfrom composer import Trainer as OriginalTrainer\nfrom composer import *  # Make all composer imports available in doctests\nfrom composer.core.logging import LogLevel\nfrom composer.core.time import Time, Timestamp\nfrom composer.datasets.synthetic import SyntheticBatchPairDataset\nfrom composer.loggers import InMemoryLogger\nfrom composer.utils import *  # Make all composer.utils imports available in doctests\n\n# Need to insert the repo root at the beginning of the path, since there may be other modules named `tests`\n# Assuming that docs generation is running from the `docs` directory\n_docs_dir = os.path.abspath(\".\")\n_repo_root = os.path.dirname(_docs_dir)\nif sys.path[0] != _repo_root:\n    sys.path.insert(0, _repo_root)\n\nfrom tests.fixtures.models import SimpleBatchPairModel\n\nnum_channels = 3\nnum_classes = 10\ndata_shape = (num_channels, 5, 5)\n\nmodel = SimpleBatchPairModel(num_channels, num_classes)\n\noptimizer = torch.optim.SGD(model.parameters(), lr=0.001)\n\nscheduler = CosineAnnealingLR(optimizer, T_max=1)\n\ndataset = SyntheticBatchPairDataset(\n    total_dataset_size=100,\n    data_shape=data_shape,\n    num_classes=num_classes,\n    num_unique_samples_to_create=10,\n)\n\ntrain_dataset = dataset\neval_dataset = dataset\n\nbatch_size = 10\n\ntrain_dataloader = torch.utils.data.DataLoader(\n    train_dataset,\n    batch_size=batch_size,\n    num_workers=0,\n    pin_memory=False,\n    drop_last=True,\n)\n\neval_dataloader = torch.utils.data.DataLoader(\n    eval_dataset,\n    batch_size=batch_size,\n    num_workers=0,\n    pin_memory=False,\n    drop_last=False,\n)\n\nstate = State(\n    rank_zero_seed=0,\n    model=model,\n    optimizers=optimizer,\n    grad_accum=1,\n    train_dataloader=train_dataloader,\n    evaluators=[],\n    max_duration=\"1ep\",\n    precision=\"fp32\",\n)\n\nlogger = Logger(state)\n\nengine = Engine(state, logger)\n\nimage = Image.fromarray(np.random.randint(0, 256, size=(32, 32, 3), dtype=np.uint8))\n\n# error: \"randn\" is not a known member of module (reportGeneralTypeIssues)\nX_example = torch.randn(batch_size, num_channels, 32, 32)  # type: ignore\n# error: \"randn\" is not a known member of module (reportGeneralTypeIssues)\nlogits = torch.randn(batch_size, num_classes)  # type: ignore\n# error: \"randint\" is not a known member of module (reportGeneralTypeIssues)\ny_example = torch.randint(num_classes, (batch_size,))  # type: ignore\n\n\n# patch the Trainer to accept ellipses\ndef Trainer(fake_ellipses='...', *args, **kwargs):\n    return OriginalTrainer(*args, **kwargs)\n\n\n# bind the required arguments to the Trainer so it can be used without arguments in the doctests\nTrainer = functools.partial(\n    Trainer,\n    model=model,\n    max_duration=\"1ep\",\n    train_dataloader=train_dataloader,\n    eval_dataloader=eval_dataloader,\n)\n\n# patch composer so that 'from composer import Trainer' calls do not override change above\ncomposer.Trainer = Trainer\n", "path": "docs/source/doctest_fixtures.py"}], "after_files": [{"content": "# Copyright 2021 MosaicML. All Rights Reserved.\n\nimport os\nimport site\nimport sys\nimport textwrap\n\nimport setuptools\nfrom setuptools import setup\nfrom setuptools.command.develop import develop as develop_orig\n\n_IS_ROOT = os.getuid() == 0\n_IS_USER = \"--user\" in sys.argv[1:]\n_IS_VIRTUALENV = \"VIRTUAL_ENV\" in os.environ\n\n\n# From https://stackoverflow.com/questions/51292333/how-to-tell-from-setup-py-if-the-module-is-being-installed-in-editable-mode\nclass develop(develop_orig):\n\n    def run(self):\n        if _IS_ROOT and (not _IS_VIRTUALENV) and (not _IS_USER):\n            raise RuntimeError(\n                textwrap.dedent(\"\"\"\\\n                    When installing in editable mode as root outside of a virtual environment,\n                    please specify `--user`. Editable installs as the root user outside of a virtual environment\n                    do not work without the `--user` flag. Please instead run something like: `pip install --user -e .`\"\"\"\n                               ))\n        super().run()\n\n\n# From https://github.com/pypa/pip/issues/7953#issuecomment-645133255\nsite.ENABLE_USER_SITE = _IS_USER\n\n\ndef package_files(directory: str):\n    # from https://stackoverflow.com/a/36693250\n    paths = []\n    for (path, _, filenames) in os.walk(directory):\n        for filename in filenames:\n            paths.append(os.path.join('..', path, filename))\n    return paths\n\n\nwith open(\"README.md\", \"r\", encoding=\"utf-8\") as fh:\n    long_description = fh.read()\n\ninstall_requires = [\n    \"pyyaml>=5.4.1\",\n    \"tqdm>=4.62.3\",\n    \"torchmetrics>=0.6.0\",\n    \"torch_optimizer==0.1.0\",\n    \"torchvision>=0.9.0\",\n    \"torch>=1.9\",\n    \"yahp>=0.1.0\",\n    \"requests>=2.26.0\",\n    \"numpy==1.21.5\",\n    \"apache-libcloud>=3.3.1\",\n    \"psutil>=5.8.0\",\n]\nextra_deps = {}\n\nextra_deps['base'] = []\n\nextra_deps['dev'] = [\n    # Imports for docs builds and running tests\n    \"custom_inherit==2.3.2\",\n    'junitparser>=2.1.1',\n    'coverage[toml]>=6.1.1',\n    'fasteners==0.17.3',  # run_directory_uploader tests require fasteners\n    'pytest>=7.0.0',\n    'toml==0.10.2',\n    'yapf==0.32.0',\n    'isort>=5.9.3',\n    'ipython>=7.29.0',\n    'ipykernel>=6.5.0',\n    'jupyter>=1.0.0',\n    'yamllint>=1.26.2',\n    'pytest-timeout>=1.4.2',\n    'recommonmark==0.7.1',\n    'sphinx>=4.4.0',\n    'docutils>=0.15',\n    'sphinx_copybutton==0.5.0',\n    'sphinx_markdown_tables==0.0.15',\n    'sphinx-argparse==0.3.1',\n    'sphinxcontrib.katex==0.8.6',\n    'sphinxext.opengraph==0.6.1',\n    'sphinxemoji==0.2.0',\n    'furo>=2022.1.2',\n    'sphinx-copybutton==0.5.0',\n    'testbook==0.4.2',\n    'myst-parser==0.16.1',\n    'pylint>=2.12.2',\n    'docformatter>=1.4',\n    'sphinx_panels==0.6.0',\n    'sphinxcontrib-images==0.9.4',\n]\n\nextra_deps[\"deepspeed\"] = [\n    'deepspeed==0.5.10',\n]\n\nextra_deps[\"wandb\"] = [\n    'wandb==0.12.10',\n    'coolname>=1.1.0',\n]\n\nextra_deps[\"unet\"] = [\n    'monai==0.8.1',\n    'scikit-learn>=1.0.1',\n]\n\nextra_deps[\"vit\"] = [\n    'vit_pytorch>=0.27',\n]\n\nextra_deps[\"timm\"] = [\n    'timm==0.5.4',\n]\n\nextra_deps[\"coco\"] = [\n    'pycocotools>=2.0.4',\n]\n\nextra_deps[\"nlp\"] = [\n    'transformers>=4.11',\n    'datasets>=1.14',\n]\n\nextra_deps['webdataset'] = [\n    'awscli>=1.22.60',\n    'webdataset @ git+https://github.com/mosaicml/webdataset.git@dev',\n    'wurlitzer>=3.0.2',\n]\n\nextra_deps['all'] = set(dep for deps in extra_deps.values() for dep in deps)\n\nsetup(name=\"mosaicml\",\n      version=\"0.4.0\",\n      author=\"MosaicML\",\n      author_email=\"team@mosaicml.com\",\n      description=\"Composer provides well-engineered implementations of efficient training methods to give \"\n      \"the tools that help you train a better model for cheaper.\",\n      long_description=long_description,\n      long_description_content_type=\"text/markdown\",\n      url=\"https://github.com/mosaicml/composer\",\n      include_package_data=True,\n      package_data={\n          \"composer\": ['py.typed'],\n          \"\": package_files('composer/yamls'),\n          \"\": package_files('composer/algorithms')\n      },\n      packages=setuptools.find_packages(exclude=[\"tests*\"]),\n      classifiers=[\n          \"Programming Language :: Python :: 3\",\n          \"Programming Language :: Python :: 3.7\",\n          \"Programming Language :: Python :: 3.8\",\n          \"Programming Language :: Python :: 3.9\",\n      ],\n      install_requires=install_requires,\n      entry_points={\n          'console_scripts': ['composer = composer.cli.launcher:main',],\n      },\n      extras_require=extra_deps,\n      dependency_links=['https://developer.download.nvidia.com/compute/redist'],\n      python_requires='>=3.7',\n      ext_package=\"composer\",\n      cmdclass={'develop': develop})\n\n# only visible if user installs with verbose -v flag\n# Printing to stdout as not to interfere with setup.py CLI flags (e.g. --version)\nprint(\"*\" * 20, file=sys.stderr)\nprint(textwrap.dedent(\"\"\"\\\n    NOTE: For best performance, we recommend installing Pillow-SIMD\n    for accelerated image processing operations. To install:\n    \\t pip uninstall pillow && pip install pillow-simd\"\"\"),\n      file=sys.stderr)\nprint(\"*\" * 20, file=sys.stderr)\n", "path": "setup.py"}, {"content": "# Copyright 2021 MosaicML. All Rights Reserved.\n\n\"\"\"\nFixtures available in doctests.\n\nThe script is run before any doctests are executed,\nso all imports and variables are available in any doctest.\nThe output of this setup script does not show up in the documentation.\n\"\"\"\nimport functools\nimport os\nimport sys\nfrom typing import Callable as Callable\n\nimport numpy as np\nimport torch.optim\nimport torch.utils.data\nfrom PIL import Image\nfrom torch.optim.lr_scheduler import CosineAnnealingLR\n\nimport composer\nfrom composer import Trainer as OriginalTrainer\nfrom composer import *  # Make all composer imports available in doctests\nfrom composer.core.logging import LogLevel as LogLevel\nfrom composer.core.time import Time as Time, Timestamp as Timestamp\nfrom composer.datasets.synthetic import SyntheticBatchPairDataset\nfrom composer.loggers import InMemoryLogger as InMemoryLogger\nfrom composer.utils import *  # Make all composer.utils imports available in doctests\n\n# Need to insert the repo root at the beginning of the path, since there may be other modules named `tests`\n# Assuming that docs generation is running from the `docs` directory\n_docs_dir = os.path.abspath(\".\")\n_repo_root = os.path.dirname(_docs_dir)\nif sys.path[0] != _repo_root:\n    sys.path.insert(0, _repo_root)\n\nfrom tests.fixtures.models import SimpleBatchPairModel\n\nnum_channels = 3\nnum_classes = 10\ndata_shape = (num_channels, 5, 5)\n\nmodel = SimpleBatchPairModel(num_channels, num_classes)\n\noptimizer = torch.optim.SGD(model.parameters(), lr=0.001)\n\nscheduler = CosineAnnealingLR(optimizer, T_max=1)\n\ndataset = SyntheticBatchPairDataset(\n    total_dataset_size=100,\n    data_shape=data_shape,\n    num_classes=num_classes,\n    num_unique_samples_to_create=10,\n)\n\ntrain_dataset = dataset\neval_dataset = dataset\n\nbatch_size = 10\n\ntrain_dataloader = torch.utils.data.DataLoader(\n    train_dataset,\n    batch_size=batch_size,\n    num_workers=0,\n    pin_memory=False,\n    drop_last=True,\n)\n\neval_dataloader = torch.utils.data.DataLoader(\n    eval_dataset,\n    batch_size=batch_size,\n    num_workers=0,\n    pin_memory=False,\n    drop_last=False,\n)\n\nstate = State(\n    rank_zero_seed=0,\n    model=model,\n    optimizers=optimizer,\n    grad_accum=1,\n    train_dataloader=train_dataloader,\n    evaluators=[],\n    max_duration=\"1ep\",\n    precision=\"fp32\",\n)\n\nlogger = Logger(state)\n\nengine = Engine(state, logger)\n\nimage = Image.fromarray(np.random.randint(0, 256, size=(32, 32, 3), dtype=np.uint8))\n\n# error: \"randn\" is not a known member of module (reportGeneralTypeIssues)\nX_example = torch.randn(batch_size, num_channels, 32, 32)  # type: ignore\n# error: \"randn\" is not a known member of module (reportGeneralTypeIssues)\nlogits = torch.randn(batch_size, num_classes)  # type: ignore\n# error: \"randint\" is not a known member of module (reportGeneralTypeIssues)\ny_example = torch.randint(num_classes, (batch_size,))  # type: ignore\n\n\n# patch the Trainer to accept ellipses\ndef Trainer(fake_ellipses='...', *args, **kwargs):\n    return OriginalTrainer(*args, **kwargs)\n\n\n# bind the required arguments to the Trainer so it can be used without arguments in the doctests\n\n# Declaration \"Trainer\" is obscured by a declaration of the same name (reportGeneralTypeIssues)\nTrainer = functools.partial(  # type: ignore\n    Trainer,\n    model=model,\n    max_duration=\"1ep\",\n    train_dataloader=train_dataloader,\n    eval_dataloader=eval_dataloader,\n)\n\n# patch composer so that 'from composer import Trainer' calls do not override change above\ncomposer.Trainer = Trainer\n", "path": "docs/source/doctest_fixtures.py"}]}