prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  [tensor] fix some unittests
  
  [tensor] fix some unittests
  
  [tensor] fix some unittests
  
  [BUG]: Testing failed due to triton
  ### 🐛 Describe the bug
  
  The build on PR workflow failed with the following errors:
  
  <img width="1509" alt="Screenshot 2023-02-07 at 10 30 17" src="https://user-images.githubusercontent.com/31818963/217132926-fd6cffa1-2c4b-46aa-a6cc-1a3d10918411.png">
  
  
  ### Environment
  
  _No response_
  
  </issue>
  <code>
  [start of colossalai/amp/apex_amp/apex_amp.py]
  1 #!/usr/bin/env python
  2 # -*- encoding: utf-8 -*-
  3 
  4 import torch.nn as nn
  5 try:
  6     import apex.amp as apex_amp
  7 except ImportError:
  8     pass
  9 
  10 from torch import Tensor
  11 
  12 from colossalai.nn.optimizer import ColossalaiOptimizer
  13 from colossalai.utils import clip_grad_norm_fp32
  14 
  15 
  16 class ApexAMPOptimizer(ColossalaiOptimizer):
  17     """ A wrapper class for APEX optimizer and it implements apex-specific backward and clip_grad_norm
  18     methods
  19     """
  20 
  21     def backward(self, loss: Tensor):
  22         """Backward pass to get all gradients
  23 
  24         Args:
  25             loss (torch.Tensor): Loss computed by a loss function
  26         """
  27         with apex_amp.scale_loss(loss, self.optim) as scaled_loss:
  28             scaled_loss.backward()
  29 
  30     def clip_grad_norm(self, model: nn.Module, max_norm: float):
  31         """Clip gradients by norm
  32 
  33         Args:
  34             model (torch.nn.Module): Your model object
  35             max_norm (float): The max norm value for gradient clipping
  36         """
  37         if max_norm > 0:
  38             clip_grad_norm_fp32(apex_amp.master_params(self.optim), max_norm)
  39
  [end of colossalai/amp/apex_amp/apex_amp.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/colossalai/amp/apex_amp/apex_amp.py b/colossalai/amp/apex_amp/apex_amp.py
  --- a/colossalai/amp/apex_amp/apex_amp.py
  +++ b/colossalai/amp/apex_amp/apex_amp.py
  @@ -2,6 +2,7 @@
   # -*- encoding: utf-8 -*-
   
   import torch.nn as nn
  +
   try:
       import apex.amp as apex_amp
   except ImportError:
  
verification_info: {"golden_diff": "diff --git a/colossalai/amp/apex_amp/apex_amp.py b/colossalai/amp/apex_amp/apex_amp.py\n--- a/colossalai/amp/apex_amp/apex_amp.py\n+++ b/colossalai/amp/apex_amp/apex_amp.py\n@@ -2,6 +2,7 @@\n # -*- encoding: utf-8 -*-\n \n import torch.nn as nn\n+\n try:\n     import apex.amp as apex_amp\n except ImportError:\n", "issue": "[tensor] fix some unittests\n\n[tensor] fix some unittests\n\n[tensor] fix some unittests\n\n[BUG]: Testing failed due to triton\n### \ud83d\udc1b Describe the bug\n\nThe build on PR workflow failed with the following errors:\r\n\r\n<img width=\"1509\" alt=\"Screenshot 2023-02-07 at 10 30 17\" src=\"https://user-images.githubusercontent.com/31818963/217132926-fd6cffa1-2c4b-46aa-a6cc-1a3d10918411.png\">\r\n\n\n### Environment\n\n_No response_\n", "before_files": [{"content": "#!/usr/bin/env python\n# -*- encoding: utf-8 -*-\n\nimport torch.nn as nn\ntry:\n    import apex.amp as apex_amp\nexcept ImportError:\n    pass\n\nfrom torch import Tensor\n\nfrom colossalai.nn.optimizer import ColossalaiOptimizer\nfrom colossalai.utils import clip_grad_norm_fp32\n\n\nclass ApexAMPOptimizer(ColossalaiOptimizer):\n    \"\"\" A wrapper class for APEX optimizer and it implements apex-specific backward and clip_grad_norm\n    methods\n    \"\"\"\n\n    def backward(self, loss: Tensor):\n        \"\"\"Backward pass to get all gradients\n\n        Args:\n            loss (torch.Tensor): Loss computed by a loss function\n        \"\"\"\n        with apex_amp.scale_loss(loss, self.optim) as scaled_loss:\n            scaled_loss.backward()\n\n    def clip_grad_norm(self, model: nn.Module, max_norm: float):\n        \"\"\"Clip gradients by norm\n\n        Args:\n            model (torch.nn.Module): Your model object\n            max_norm (float): The max norm value for gradient clipping\n        \"\"\"\n        if max_norm > 0:\n            clip_grad_norm_fp32(apex_amp.master_params(self.optim), max_norm)\n", "path": "colossalai/amp/apex_amp/apex_amp.py"}]}