We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
`warnings.simplefilter('default')` in global scope causes excessive DeprecationWarnings
https://github.com/NVIDIA/TransformerEngine/blob/f85553ea369da15fd726ab279818e415be48a228/transformer_engine/common/utils.py#L9

Importing the `transformer_engine.common.utils` resets the warning filters to default settings using `warnings.simplefilter('default')` in the global scope. This results in the console being flooded with DeprecationWarnings, which are normally ignored by Python by default.

Would it be possible to move setting the warning filter config to a more controlled scope in this module?

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `transformer_engine/common/utils.py`
Content:
```
1 # Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2 #
3 # See LICENSE for license information.
4 """The utilities for Transformer Engine"""
5 import inspect
6 import warnings
7 from enum import Enum
8 
9 warnings.simplefilter('default')
10 
11 
12 class DeprecatedEnum:    # pylint: disable=too-few-public-methods
13     """DeprecatedEnum"""
14 
15     def __init__(self, enum_cls, msg):
16         self.enum_cls = enum_cls
17         self.msg = msg
18 
19     def __iter__(self):
20         return iter(list(self.enum_cls.__members__.values()))
21 
22     def __getattr__(self, name):
23         if name in self.enum_cls.__members__:
24             warnings.warn(self.msg, DeprecationWarning)
25             return self.enum_cls.__members__[name]
26         raise AttributeError(f"{self.enum_cls} does not contain {name}")
27 
28 
29 def deprecate_wrapper(obj, msg):
30     """Deprecate wrapper"""
31     if inspect.isclass(obj):
32         if issubclass(obj, Enum):
33             return DeprecatedEnum(obj, msg)
34 
35         class DeprecatedCls(obj):    # pylint: disable=too-few-public-methods
36             """DeprecatedCls"""
37 
38             def __init__(self, *args, **kwargs):
39                 warnings.warn(msg, DeprecationWarning)
40                 super().__init__(*args, **kwargs)
41 
42         return DeprecatedCls
43 
44     if inspect.isfunction(obj):
45 
46         def deprecated(*args, **kwargs):
47             warnings.warn(msg, DeprecationWarning)
48             return obj(*args, **kwargs)
49 
50         return deprecated
51 
52     raise NotImplementedError(
53         f"deprecate_cls_wrapper only support Class and Function, but got {type(obj)}.")
54
```
--- 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/transformer_engine/common/utils.py b/transformer_engine/common/utils.py
--- a/transformer_engine/common/utils.py
+++ b/transformer_engine/common/utils.py
@@ -6,7 +6,8 @@
 import warnings
 from enum import Enum
 
-warnings.simplefilter('default')
+warnings.filterwarnings(
+    "module", category=DeprecationWarning, module="transformer_engine.common.utils")
 
 
 class DeprecatedEnum:    # pylint: disable=too-few-public-methods

{"golden_diff": "diff --git a/transformer_engine/common/utils.py b/transformer_engine/common/utils.py\n--- a/transformer_engine/common/utils.py\n+++ b/transformer_engine/common/utils.py\n@@ -6,7 +6,8 @@\n import warnings\n from enum import Enum\n \n-warnings.simplefilter('default')\n+warnings.filterwarnings(\n+    \"module\", category=DeprecationWarning, module=\"transformer_engine.common.utils\")\n \n \n class DeprecatedEnum:    # pylint: disable=too-few-public-methods\n", "issue": "`warnings.simplefilter('default')` in global scope causes excessive DeprecationWarnings\nhttps://github.com/NVIDIA/TransformerEngine/blob/f85553ea369da15fd726ab279818e415be48a228/transformer_engine/common/utils.py#L9\r\n\r\nImporting the `transformer_engine.common.utils` resets the warning filters to default settings using `warnings.simplefilter('default')` in the global scope. This results in the console being flooded with DeprecationWarnings, which are normally ignored by Python by default.\r\n\r\nWould it be possible to move setting the warning filter config to a more controlled scope in this module?\n", "before_files": [{"content": "# Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n#\n# See LICENSE for license information.\n\"\"\"The utilities for Transformer Engine\"\"\"\nimport inspect\nimport warnings\nfrom enum import Enum\n\nwarnings.simplefilter('default')\n\n\nclass DeprecatedEnum:    # pylint: disable=too-few-public-methods\n    \"\"\"DeprecatedEnum\"\"\"\n\n    def __init__(self, enum_cls, msg):\n        self.enum_cls = enum_cls\n        self.msg = msg\n\n    def __iter__(self):\n        return iter(list(self.enum_cls.__members__.values()))\n\n    def __getattr__(self, name):\n        if name in self.enum_cls.__members__:\n            warnings.warn(self.msg, DeprecationWarning)\n            return self.enum_cls.__members__[name]\n        raise AttributeError(f\"{self.enum_cls} does not contain {name}\")\n\n\ndef deprecate_wrapper(obj, msg):\n    \"\"\"Deprecate wrapper\"\"\"\n    if inspect.isclass(obj):\n        if issubclass(obj, Enum):\n            return DeprecatedEnum(obj, msg)\n\n        class DeprecatedCls(obj):    # pylint: disable=too-few-public-methods\n            \"\"\"DeprecatedCls\"\"\"\n\n            def __init__(self, *args, **kwargs):\n                warnings.warn(msg, DeprecationWarning)\n                super().__init__(*args, **kwargs)\n\n        return DeprecatedCls\n\n    if inspect.isfunction(obj):\n\n        def deprecated(*args, **kwargs):\n            warnings.warn(msg, DeprecationWarning)\n            return obj(*args, **kwargs)\n\n        return deprecated\n\n    raise NotImplementedError(\n        f\"deprecate_cls_wrapper only support Class and Function, but got {type(obj)}.\")\n", "path": "transformer_engine/common/utils.py"}], "after_files": [{"content": "# Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n#\n# See LICENSE for license information.\n\"\"\"The utilities for Transformer Engine\"\"\"\nimport inspect\nimport warnings\nfrom enum import Enum\n\nwarnings.filterwarnings(\n    \"module\", category=DeprecationWarning, module=\"transformer_engine.common.utils\")\n\n\nclass DeprecatedEnum:    # pylint: disable=too-few-public-methods\n    \"\"\"DeprecatedEnum\"\"\"\n\n    def __init__(self, enum_cls, msg):\n        self.enum_cls = enum_cls\n        self.msg = msg\n\n    def __iter__(self):\n        return iter(list(self.enum_cls.__members__.values()))\n\n    def __getattr__(self, name):\n        if name in self.enum_cls.__members__:\n            warnings.warn(self.msg, DeprecationWarning)\n            return self.enum_cls.__members__[name]\n        raise AttributeError(f\"{self.enum_cls} does not contain {name}\")\n\n\ndef deprecate_wrapper(obj, msg):\n    \"\"\"Deprecate wrapper\"\"\"\n    if inspect.isclass(obj):\n        if issubclass(obj, Enum):\n            return DeprecatedEnum(obj, msg)\n\n        class DeprecatedCls(obj):    # pylint: disable=too-few-public-methods\n            \"\"\"DeprecatedCls\"\"\"\n\n            def __init__(self, *args, **kwargs):\n                warnings.warn(msg, DeprecationWarning)\n                super().__init__(*args, **kwargs)\n\n        return DeprecatedCls\n\n    if inspect.isfunction(obj):\n\n        def deprecated(*args, **kwargs):\n            warnings.warn(msg, DeprecationWarning)\n            return obj(*args, **kwargs)\n\n        return deprecated\n\n    raise NotImplementedError(\n        f\"deprecate_cls_wrapper only support Class and Function, but got {type(obj)}.\")\n", "path": "transformer_engine/common/utils.py"}]}