prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Pylint: W0707
  ```bash
  mmpose/utils/hooks.py:37:20: W0707: Consider explicitly re-raising using the 'from' keyword (raise-missing-from)
  ```
  
  </issue>
  <code>
  [start of mmpose/utils/hooks.py]
  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 of mmpose/utils/hooks.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: 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):
  
verification_info: {"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"}]}