We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Lots of Commandline Output from this line.

https://github.com/facebookresearch/fairscale/blob/2350968ee61a6f9ca6ecd24aba9db536e814a24c/fairscale/internal/version.py#L27

this warning appears a LOT in the commandline output when training. Can we remove it or place it in a place where it gets only shown once at the start?


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `fairscale/internal/version.py`
Content:
```
1 # Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
2 #
3 # This source code is licensed under the BSD license found in the
4 # LICENSE file in the root directory of this source tree.
5 
6 import logging
7 import re
8 from typing import List, Tuple
9 
10 import torch
11 
12 __all__: List[str] = ["torch_version"]
13 
14 
15 def torch_version(version: str = torch.__version__) -> Tuple[int, ...]:
16     numbering = re.search(r"^(\d+).(\d+).(\d+)([^\+]*)(\+\S*)?$", version)
17     if not numbering:
18         return tuple()
19     # Catch torch version if run against internal pre-releases, like `1.8.0a0fb`,
20     if numbering.group(4):
21         # Two options here:
22         # - either skip this version (minor number check is not relevant)
23         # - or check that our codebase is not broken by this ongoing development.
24 
25         # Assuming that we're interested in the second use-case more than the first,
26         # return the pre-release or dev numbering
27         logging.warning(f"Pytorch pre-release version {version} - assuming intent to test it")
28 
29     return tuple(int(numbering.group(n)) for n in range(1, 4))
30
```
--- 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/fairscale/internal/version.py b/fairscale/internal/version.py
--- a/fairscale/internal/version.py
+++ b/fairscale/internal/version.py
@@ -11,13 +11,15 @@
 
 __all__: List[str] = ["torch_version"]
 
+_logged = False
 
 def torch_version(version: str = torch.__version__) -> Tuple[int, ...]:
     numbering = re.search(r"^(\d+).(\d+).(\d+)([^\+]*)(\+\S*)?$", version)
     if not numbering:
         return tuple()
     # Catch torch version if run against internal pre-releases, like `1.8.0a0fb`,
-    if numbering.group(4):
+    global _logged
+    if numbering.group(4) and not _logged:
         # Two options here:
         # - either skip this version (minor number check is not relevant)
         # - or check that our codebase is not broken by this ongoing development.
@@ -25,5 +27,6 @@
         # Assuming that we're interested in the second use-case more than the first,
         # return the pre-release or dev numbering
         logging.warning(f"Pytorch pre-release version {version} - assuming intent to test it")
+        _logged = True
 
     return tuple(int(numbering.group(n)) for n in range(1, 4))

{"golden_diff": "diff --git a/fairscale/internal/version.py b/fairscale/internal/version.py\n--- a/fairscale/internal/version.py\n+++ b/fairscale/internal/version.py\n@@ -11,13 +11,15 @@\n \n __all__: List[str] = [\"torch_version\"]\n \n+_logged = False\n \n def torch_version(version: str = torch.__version__) -> Tuple[int, ...]:\n     numbering = re.search(r\"^(\\d+).(\\d+).(\\d+)([^\\+]*)(\\+\\S*)?$\", version)\n     if not numbering:\n         return tuple()\n     # Catch torch version if run against internal pre-releases, like `1.8.0a0fb`,\n-    if numbering.group(4):\n+    global _logged\n+    if numbering.group(4) and not _logged:\n         # Two options here:\n         # - either skip this version (minor number check is not relevant)\n         # - or check that our codebase is not broken by this ongoing development.\n@@ -25,5 +27,6 @@\n         # Assuming that we're interested in the second use-case more than the first,\n         # return the pre-release or dev numbering\n         logging.warning(f\"Pytorch pre-release version {version} - assuming intent to test it\")\n+        _logged = True\n \n     return tuple(int(numbering.group(n)) for n in range(1, 4))\n", "issue": "Lots of Commandline Output from this line.\n\r\nhttps://github.com/facebookresearch/fairscale/blob/2350968ee61a6f9ca6ecd24aba9db536e814a24c/fairscale/internal/version.py#L27\r\n\r\nthis warning appears a LOT in the commandline output when training. Can we remove it or place it in a place where it gets only shown once at the start?\r\n\n", "before_files": [{"content": "# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.\n#\n# This source code is licensed under the BSD license found in the\n# LICENSE file in the root directory of this source tree.\n\nimport logging\nimport re\nfrom typing import List, Tuple\n\nimport torch\n\n__all__: List[str] = [\"torch_version\"]\n\n\ndef torch_version(version: str = torch.__version__) -> Tuple[int, ...]:\n    numbering = re.search(r\"^(\\d+).(\\d+).(\\d+)([^\\+]*)(\\+\\S*)?$\", version)\n    if not numbering:\n        return tuple()\n    # Catch torch version if run against internal pre-releases, like `1.8.0a0fb`,\n    if numbering.group(4):\n        # Two options here:\n        # - either skip this version (minor number check is not relevant)\n        # - or check that our codebase is not broken by this ongoing development.\n\n        # Assuming that we're interested in the second use-case more than the first,\n        # return the pre-release or dev numbering\n        logging.warning(f\"Pytorch pre-release version {version} - assuming intent to test it\")\n\n    return tuple(int(numbering.group(n)) for n in range(1, 4))\n", "path": "fairscale/internal/version.py"}], "after_files": [{"content": "# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.\n#\n# This source code is licensed under the BSD license found in the\n# LICENSE file in the root directory of this source tree.\n\nimport logging\nimport re\nfrom typing import List, Tuple\n\nimport torch\n\n__all__: List[str] = [\"torch_version\"]\n\n_logged = False\n\ndef torch_version(version: str = torch.__version__) -> Tuple[int, ...]:\n    numbering = re.search(r\"^(\\d+).(\\d+).(\\d+)([^\\+]*)(\\+\\S*)?$\", version)\n    if not numbering:\n        return tuple()\n    # Catch torch version if run against internal pre-releases, like `1.8.0a0fb`,\n    global _logged\n    if numbering.group(4) and not _logged:\n        # Two options here:\n        # - either skip this version (minor number check is not relevant)\n        # - or check that our codebase is not broken by this ongoing development.\n\n        # Assuming that we're interested in the second use-case more than the first,\n        # return the pre-release or dev numbering\n        logging.warning(f\"Pytorch pre-release version {version} - assuming intent to test it\")\n        _logged = True\n\n    return tuple(int(numbering.group(n)) for n in range(1, 4))\n", "path": "fairscale/internal/version.py"}]}