We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Pylint: W0707
```bash
mmpose/utils/hooks.py:37:20: W0707: Consider explicitly re-raising using the 'from' keyword (raise-missing-from)
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `mmpose/utils/hooks.py`
Content:
```
1 import functools
2 
3 
4 class OutputHook:
5 
6     def __init__(self, module, outputs=None, as_tensor=False):
7         self.outputs = outputs
8         self.as_tensor = as_tensor
9         self.layer_outputs = {}
10         self.register(module)
11 
12     def register(self, module):
13 
14         def hook_wrapper(name):
15 
16             def hook(model, input, output):
17                 if self.as_tensor:
18                     self.layer_outputs[name] = output
19                 else:
20                     if isinstance(output, list):
21                         self.layer_outputs[name] = [
22                             out.detach().cpu().numpy() for out in output
23                         ]
24                     else:
25                         self.layer_outputs[name] = output.detach().cpu().numpy(
26                         )
27 
28             return hook
29 
30         self.handles = []
31         if isinstance(self.outputs, (list, tuple)):
32             for name in self.outputs:
33                 try:
34                     layer = rgetattr(module, name)
35                     h = layer.register_forward_hook(hook_wrapper(name))
36                 except AttributeError:
37                     raise AttributeError(f'Module {name} not found')
38                 self.handles.append(h)
39 
40     def remove(self):
41         for h in self.handles:
42             h.remove()
43 
44     def __enter__(self):
45         return self
46 
47     def __exit__(self, exc_type, exc_val, exc_tb):
48         self.remove()
49 
50 
51 # using wonder's beautiful simplification:
52 # https://stackoverflow.com/questions/31174295/getattr-and-setattr-on-nested-objects
53 def rgetattr(obj, attr, *args):
54 
55     def _getattr(obj, attr):
56         return getattr(obj, attr, *args)
57 
58     return functools.reduce(_getattr, [obj] + attr.split('.'))
59
```
--- 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/mmpose/utils/hooks.py b/mmpose/utils/hooks.py
--- a/mmpose/utils/hooks.py
+++ b/mmpose/utils/hooks.py
@@ -33,8 +33,9 @@
                 try:
                     layer = rgetattr(module, name)
                     h = layer.register_forward_hook(hook_wrapper(name))
-                except AttributeError:
-                    raise AttributeError(f'Module {name} not found')
+                except ModuleNotFoundError as module_not_found:
+                    raise ModuleNotFoundError(
+                        f'Module {name} not found') from module_not_found
                 self.handles.append(h)
 
     def remove(self):

{"golden_diff": "diff --git a/mmpose/utils/hooks.py b/mmpose/utils/hooks.py\n--- a/mmpose/utils/hooks.py\n+++ b/mmpose/utils/hooks.py\n@@ -33,8 +33,9 @@\n                 try:\n                     layer = rgetattr(module, name)\n                     h = layer.register_forward_hook(hook_wrapper(name))\n-                except AttributeError:\n-                    raise AttributeError(f'Module {name} not found')\n+                except ModuleNotFoundError as module_not_found:\n+                    raise ModuleNotFoundError(\n+                        f'Module {name} not found') from module_not_found\n                 self.handles.append(h)\n \n     def remove(self):\n", "issue": "Pylint: W0707\n```bash\r\nmmpose/utils/hooks.py:37:20: W0707: Consider explicitly re-raising using the 'from' keyword (raise-missing-from)\r\n```\n", "before_files": [{"content": "import functools\n\n\nclass OutputHook:\n\n    def __init__(self, module, outputs=None, as_tensor=False):\n        self.outputs = outputs\n        self.as_tensor = as_tensor\n        self.layer_outputs = {}\n        self.register(module)\n\n    def register(self, module):\n\n        def hook_wrapper(name):\n\n            def hook(model, input, output):\n                if self.as_tensor:\n                    self.layer_outputs[name] = output\n                else:\n                    if isinstance(output, list):\n                        self.layer_outputs[name] = [\n                            out.detach().cpu().numpy() for out in output\n                        ]\n                    else:\n                        self.layer_outputs[name] = output.detach().cpu().numpy(\n                        )\n\n            return hook\n\n        self.handles = []\n        if isinstance(self.outputs, (list, tuple)):\n            for name in self.outputs:\n                try:\n                    layer = rgetattr(module, name)\n                    h = layer.register_forward_hook(hook_wrapper(name))\n                except AttributeError:\n                    raise AttributeError(f'Module {name} not found')\n                self.handles.append(h)\n\n    def remove(self):\n        for h in self.handles:\n            h.remove()\n\n    def __enter__(self):\n        return self\n\n    def __exit__(self, exc_type, exc_val, exc_tb):\n        self.remove()\n\n\n# using wonder's beautiful simplification:\n# https://stackoverflow.com/questions/31174295/getattr-and-setattr-on-nested-objects\ndef rgetattr(obj, attr, *args):\n\n    def _getattr(obj, attr):\n        return getattr(obj, attr, *args)\n\n    return functools.reduce(_getattr, [obj] + attr.split('.'))\n", "path": "mmpose/utils/hooks.py"}], "after_files": [{"content": "import functools\n\n\nclass OutputHook:\n\n    def __init__(self, module, outputs=None, as_tensor=False):\n        self.outputs = outputs\n        self.as_tensor = as_tensor\n        self.layer_outputs = {}\n        self.register(module)\n\n    def register(self, module):\n\n        def hook_wrapper(name):\n\n            def hook(model, input, output):\n                if self.as_tensor:\n                    self.layer_outputs[name] = output\n                else:\n                    if isinstance(output, list):\n                        self.layer_outputs[name] = [\n                            out.detach().cpu().numpy() for out in output\n                        ]\n                    else:\n                        self.layer_outputs[name] = output.detach().cpu().numpy(\n                        )\n\n            return hook\n\n        self.handles = []\n        if isinstance(self.outputs, (list, tuple)):\n            for name in self.outputs:\n                try:\n                    layer = rgetattr(module, name)\n                    h = layer.register_forward_hook(hook_wrapper(name))\n                except ModuleNotFoundError as module_not_found:\n                    raise ModuleNotFoundError(\n                        f'Module {name} not found') from module_not_found\n                self.handles.append(h)\n\n    def remove(self):\n        for h in self.handles:\n            h.remove()\n\n    def __enter__(self):\n        return self\n\n    def __exit__(self, exc_type, exc_val, exc_tb):\n        self.remove()\n\n\n# using wonder's beautiful simplification:\n# https://stackoverflow.com/questions/31174295/getattr-and-setattr-on-nested-objects\ndef rgetattr(obj, attr, *args):\n\n    def _getattr(obj, attr):\n        return getattr(obj, attr, *args)\n\n    return functools.reduce(_getattr, [obj] + attr.split('.'))\n", "path": "mmpose/utils/hooks.py"}]}