prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  jtnn example error
  NOCUDA=1 python3 vaetrain_dgl.py
  it shows NameError: name 'tensor' is not defined in dgl/examples/pytorch/jtnn/jtnn/nnutils.py", line 11, in cuda
      return tensor
  
  env: 
  dgl 0.5.3
  torch 1.7.1
  mac os
  
  
  
  
  </issue>
  <code>
  [start of examples/pytorch/jtnn/jtnn/nnutils.py]
  1 import torch
  2 import torch.nn as nn
  3 import os
  4 import dgl
  5 
  6 
  7 def cuda(x):
  8     if torch.cuda.is_available() and not os.getenv('NOCUDA', None):
  9         return x.to(torch.device('cuda'))   # works for both DGLGraph and tensor
  10     else:
  11         return tensor
  12 
  13 
  14 class GRUUpdate(nn.Module):
  15     def __init__(self, hidden_size):
  16         nn.Module.__init__(self)
  17         self.hidden_size = hidden_size
  18 
  19         self.W_z = nn.Linear(2 * hidden_size, hidden_size)
  20         self.W_r = nn.Linear(hidden_size, hidden_size, bias=False)
  21         self.U_r = nn.Linear(hidden_size, hidden_size)
  22         self.W_h = nn.Linear(2 * hidden_size, hidden_size)
  23 
  24     def update_zm(self, node):
  25         src_x = node.data['src_x']
  26         s = node.data['s']
  27         rm = node.data['accum_rm']
  28         z = torch.sigmoid(self.W_z(torch.cat([src_x, s], 1)))
  29         m = torch.tanh(self.W_h(torch.cat([src_x, rm], 1)))
  30         m = (1 - z) * s + z * m
  31         return {'m': m, 'z': z}
  32 
  33     def update_r(self, node, zm=None):
  34         dst_x = node.data['dst_x']
  35         m = node.data['m'] if zm is None else zm['m']
  36         r_1 = self.W_r(dst_x)
  37         r_2 = self.U_r(m)
  38         r = torch.sigmoid(r_1 + r_2)
  39         return {'r': r, 'rm': r * m}
  40 
  41     def forward(self, node):
  42         dic = self.update_zm(node)
  43         dic.update(self.update_r(node, zm=dic))
  44         return dic
  45 
  46 def tocpu(g):
  47     src, dst = g.edges()
  48     src = src.cpu()
  49     dst = dst.cpu()
  50     return dgl.graph((src, dst), num_nodes=g.number_of_nodes())
  51
  [end of examples/pytorch/jtnn/jtnn/nnutils.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/examples/pytorch/jtnn/jtnn/nnutils.py b/examples/pytorch/jtnn/jtnn/nnutils.py
  --- a/examples/pytorch/jtnn/jtnn/nnutils.py
  +++ b/examples/pytorch/jtnn/jtnn/nnutils.py
  @@ -8,7 +8,7 @@
       if torch.cuda.is_available() and not os.getenv('NOCUDA', None):
           return x.to(torch.device('cuda'))   # works for both DGLGraph and tensor
       else:
  -        return tensor
  +        return x
   
   
   class GRUUpdate(nn.Module):
  
verification_info: {"golden_diff": "diff --git a/examples/pytorch/jtnn/jtnn/nnutils.py b/examples/pytorch/jtnn/jtnn/nnutils.py\n--- a/examples/pytorch/jtnn/jtnn/nnutils.py\n+++ b/examples/pytorch/jtnn/jtnn/nnutils.py\n@@ -8,7 +8,7 @@\n     if torch.cuda.is_available() and not os.getenv('NOCUDA', None):\n         return x.to(torch.device('cuda'))   # works for both DGLGraph and tensor\n     else:\n-        return tensor\n+        return x\n \n \n class GRUUpdate(nn.Module):\n", "issue": "jtnn example error\nNOCUDA=1 python3 vaetrain_dgl.py\r\nit shows NameError: name 'tensor' is not defined in dgl/examples/pytorch/jtnn/jtnn/nnutils.py\", line 11, in cuda\r\n    return tensor\r\n\r\nenv: \r\ndgl 0.5.3\r\ntorch 1.7.1\r\nmac os\r\n\r\n\r\n\n", "before_files": [{"content": "import torch\nimport torch.nn as nn\nimport os\nimport dgl\n\n\ndef cuda(x):\n    if torch.cuda.is_available() and not os.getenv('NOCUDA', None):\n        return x.to(torch.device('cuda'))   # works for both DGLGraph and tensor\n    else:\n        return tensor\n\n\nclass GRUUpdate(nn.Module):\n    def __init__(self, hidden_size):\n        nn.Module.__init__(self)\n        self.hidden_size = hidden_size\n\n        self.W_z = nn.Linear(2 * hidden_size, hidden_size)\n        self.W_r = nn.Linear(hidden_size, hidden_size, bias=False)\n        self.U_r = nn.Linear(hidden_size, hidden_size)\n        self.W_h = nn.Linear(2 * hidden_size, hidden_size)\n\n    def update_zm(self, node):\n        src_x = node.data['src_x']\n        s = node.data['s']\n        rm = node.data['accum_rm']\n        z = torch.sigmoid(self.W_z(torch.cat([src_x, s], 1)))\n        m = torch.tanh(self.W_h(torch.cat([src_x, rm], 1)))\n        m = (1 - z) * s + z * m\n        return {'m': m, 'z': z}\n\n    def update_r(self, node, zm=None):\n        dst_x = node.data['dst_x']\n        m = node.data['m'] if zm is None else zm['m']\n        r_1 = self.W_r(dst_x)\n        r_2 = self.U_r(m)\n        r = torch.sigmoid(r_1 + r_2)\n        return {'r': r, 'rm': r * m}\n\n    def forward(self, node):\n        dic = self.update_zm(node)\n        dic.update(self.update_r(node, zm=dic))\n        return dic\n\ndef tocpu(g):\n    src, dst = g.edges()\n    src = src.cpu()\n    dst = dst.cpu()\n    return dgl.graph((src, dst), num_nodes=g.number_of_nodes())\n", "path": "examples/pytorch/jtnn/jtnn/nnutils.py"}]}