We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN 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




--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `examples/pytorch/jtnn/jtnn/nnutils.py`
Content:
```
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 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/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):

{"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"}], "after_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 x\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"}]}