We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
link.LSTM.to_cpu (resp. to_gpu) does not move state variables to CPU (resp. GPU).
When `link.LSTM` is move to CPU (resp. GPU), its state variables should also be moved to CPU(resp. GPU). But it does not.

```
In [39]: l = chainer.links.LSTM(10, 10)

In [40]: l.xp
Out[40]: <module 'numpy' from '/home/delta/.pyenv/versions/pyenv-2.7.9/lib/python2.7/site-packages/numpy/__init__.pyc'>

In [41]: x = chainer.Variable(numpy.random.uniform(-1, 1, (5, 10)).astype(numpy.float32))

In [42]: l(x)
Out[42]: <variable at 0x7fe900a88d90>

In [43]: type(l.h.data)
Out[43]: numpy.ndarray

In [44]: l.to_gpu()
Out[44]: <chainer.links.connection.lstm.LSTM at 0x7fe900a42a10>

In [45]: l.xp
Out[45]: <module 'cupy' from 'cupy/__init__.pyc'>

In [46]: type(l.h.data)
Out[46]: numpy.ndarray

In [47]: type(l.c.data)
Out[47]: numpy.ndarray
```

The output of [46] and [47] should be `cupy.ndarray`


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `chainer/links/connection/lstm.py`
Content:
```
1 from chainer.functions.activation import lstm
2 from chainer import link
3 from chainer.links.connection import linear
4 from chainer import variable
5 
6 
7 class LSTM(link.Chain):
8 
9     """Fully-connected LSTM layer.
10 
11     This is a fully-connected LSTM layer as a chain. Unlike the
12     :func:`~chainer.functions.lstm` function, which is defined as a stateless
13     activation function, this chain holds upward and lateral connections as
14     child links.
15 
16     It also maintains *states*, including the cell state and the output
17     at the previous time step. Therefore, it can be used as a *stateful LSTM*.
18 
19     Args:
20         in_size (int): Dimensionality of input vectors.
21         out_size (int): Dimensionality of output vectors.
22 
23     Attributes:
24         upward (chainer.links.Linear): Linear layer of upward connections.
25         lateral (chainer.links.Linear): Linear layer of lateral connections.
26         c (chainer.Variable): Cell states of LSTM units.
27         h (chainer.Variable): Output at the previous timestep.
28 
29     """
30     def __init__(self, in_size, out_size):
31         super(LSTM, self).__init__(
32             upward=linear.Linear(in_size, 4 * out_size),
33             lateral=linear.Linear(out_size, 4 * out_size, nobias=True),
34         )
35         self.state_size = out_size
36         self.reset_state()
37 
38     def reset_state(self):
39         """Resets the internal state.
40 
41         It sets None to the :attr:`c` and :attr:`h` attributes.
42 
43         """
44         self.c = self.h = None
45 
46     def __call__(self, x):
47         """Updates the internal state and returns the LSTM outputs.
48 
49         Args:
50             x (~chainer.Variable): A new batch from the input sequence.
51 
52         Returns:
53             ~chainer.Variable: Outputs of updated LSTM units.
54 
55         """
56         lstm_in = self.upward(x)
57         if self.h is not None:
58             lstm_in += self.lateral(self.h)
59         if self.c is None:
60             xp = self.xp
61             self.c = variable.Variable(
62                 xp.zeros((len(x.data), self.state_size), dtype=x.data.dtype),
63                 volatile='auto')
64         self.c, self.h = lstm.lstm(self.c, lstm_in)
65         return self.h
66
```
--- 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/chainer/links/connection/lstm.py b/chainer/links/connection/lstm.py
--- a/chainer/links/connection/lstm.py
+++ b/chainer/links/connection/lstm.py
@@ -35,6 +35,20 @@
         self.state_size = out_size
         self.reset_state()
 
+    def to_cpu(self):
+        super(LSTM, self).to_cpu()
+        if self.c is not None:
+            self.c.to_cpu()
+        if self.h is not None:
+            self.h.to_cpu()
+
+    def to_gpu(self, device=None):
+        super(LSTM, self).to_gpu(device)
+        if self.c is not None:
+            self.c.to_gpu(device)
+        if self.h is not None:
+            self.h.to_gpu(device)
+
     def reset_state(self):
         """Resets the internal state.

{"golden_diff": "diff --git a/chainer/links/connection/lstm.py b/chainer/links/connection/lstm.py\n--- a/chainer/links/connection/lstm.py\n+++ b/chainer/links/connection/lstm.py\n@@ -35,6 +35,20 @@\n         self.state_size = out_size\n         self.reset_state()\n \n+    def to_cpu(self):\n+        super(LSTM, self).to_cpu()\n+        if self.c is not None:\n+            self.c.to_cpu()\n+        if self.h is not None:\n+            self.h.to_cpu()\n+\n+    def to_gpu(self, device=None):\n+        super(LSTM, self).to_gpu(device)\n+        if self.c is not None:\n+            self.c.to_gpu(device)\n+        if self.h is not None:\n+            self.h.to_gpu(device)\n+\n     def reset_state(self):\n         \"\"\"Resets the internal state.\n", "issue": "link.LSTM.to_cpu (resp. to_gpu) does not move state variables to CPU (resp. GPU).\nWhen `link.LSTM` is move to CPU (resp. GPU), its state variables should also be moved to CPU(resp. GPU). But it does not.\n\n```\nIn [39]: l = chainer.links.LSTM(10, 10)\n\nIn [40]: l.xp\nOut[40]: <module 'numpy' from '/home/delta/.pyenv/versions/pyenv-2.7.9/lib/python2.7/site-packages/numpy/__init__.pyc'>\n\nIn [41]: x = chainer.Variable(numpy.random.uniform(-1, 1, (5, 10)).astype(numpy.float32))\n\nIn [42]: l(x)\nOut[42]: <variable at 0x7fe900a88d90>\n\nIn [43]: type(l.h.data)\nOut[43]: numpy.ndarray\n\nIn [44]: l.to_gpu()\nOut[44]: <chainer.links.connection.lstm.LSTM at 0x7fe900a42a10>\n\nIn [45]: l.xp\nOut[45]: <module 'cupy' from 'cupy/__init__.pyc'>\n\nIn [46]: type(l.h.data)\nOut[46]: numpy.ndarray\n\nIn [47]: type(l.c.data)\nOut[47]: numpy.ndarray\n```\n\nThe output of [46] and [47] should be `cupy.ndarray`\n\n", "before_files": [{"content": "from chainer.functions.activation import lstm\nfrom chainer import link\nfrom chainer.links.connection import linear\nfrom chainer import variable\n\n\nclass LSTM(link.Chain):\n\n    \"\"\"Fully-connected LSTM layer.\n\n    This is a fully-connected LSTM layer as a chain. Unlike the\n    :func:`~chainer.functions.lstm` function, which is defined as a stateless\n    activation function, this chain holds upward and lateral connections as\n    child links.\n\n    It also maintains *states*, including the cell state and the output\n    at the previous time step. Therefore, it can be used as a *stateful LSTM*.\n\n    Args:\n        in_size (int): Dimensionality of input vectors.\n        out_size (int): Dimensionality of output vectors.\n\n    Attributes:\n        upward (chainer.links.Linear): Linear layer of upward connections.\n        lateral (chainer.links.Linear): Linear layer of lateral connections.\n        c (chainer.Variable): Cell states of LSTM units.\n        h (chainer.Variable): Output at the previous timestep.\n\n    \"\"\"\n    def __init__(self, in_size, out_size):\n        super(LSTM, self).__init__(\n            upward=linear.Linear(in_size, 4 * out_size),\n            lateral=linear.Linear(out_size, 4 * out_size, nobias=True),\n        )\n        self.state_size = out_size\n        self.reset_state()\n\n    def reset_state(self):\n        \"\"\"Resets the internal state.\n\n        It sets None to the :attr:`c` and :attr:`h` attributes.\n\n        \"\"\"\n        self.c = self.h = None\n\n    def __call__(self, x):\n        \"\"\"Updates the internal state and returns the LSTM outputs.\n\n        Args:\n            x (~chainer.Variable): A new batch from the input sequence.\n\n        Returns:\n            ~chainer.Variable: Outputs of updated LSTM units.\n\n        \"\"\"\n        lstm_in = self.upward(x)\n        if self.h is not None:\n            lstm_in += self.lateral(self.h)\n        if self.c is None:\n            xp = self.xp\n            self.c = variable.Variable(\n                xp.zeros((len(x.data), self.state_size), dtype=x.data.dtype),\n                volatile='auto')\n        self.c, self.h = lstm.lstm(self.c, lstm_in)\n        return self.h\n", "path": "chainer/links/connection/lstm.py"}], "after_files": [{"content": "from chainer.functions.activation import lstm\nfrom chainer import link\nfrom chainer.links.connection import linear\nfrom chainer import variable\n\n\nclass LSTM(link.Chain):\n\n    \"\"\"Fully-connected LSTM layer.\n\n    This is a fully-connected LSTM layer as a chain. Unlike the\n    :func:`~chainer.functions.lstm` function, which is defined as a stateless\n    activation function, this chain holds upward and lateral connections as\n    child links.\n\n    It also maintains *states*, including the cell state and the output\n    at the previous time step. Therefore, it can be used as a *stateful LSTM*.\n\n    Args:\n        in_size (int): Dimensionality of input vectors.\n        out_size (int): Dimensionality of output vectors.\n\n    Attributes:\n        upward (chainer.links.Linear): Linear layer of upward connections.\n        lateral (chainer.links.Linear): Linear layer of lateral connections.\n        c (chainer.Variable): Cell states of LSTM units.\n        h (chainer.Variable): Output at the previous timestep.\n\n    \"\"\"\n    def __init__(self, in_size, out_size):\n        super(LSTM, self).__init__(\n            upward=linear.Linear(in_size, 4 * out_size),\n            lateral=linear.Linear(out_size, 4 * out_size, nobias=True),\n        )\n        self.state_size = out_size\n        self.reset_state()\n\n    def to_cpu(self):\n        super(LSTM, self).to_cpu()\n        if self.c is not None:\n            self.c.to_cpu()\n        if self.h is not None:\n            self.h.to_cpu()\n\n    def to_gpu(self, device=None):\n        super(LSTM, self).to_gpu(device)\n        if self.c is not None:\n            self.c.to_gpu(device)\n        if self.h is not None:\n            self.h.to_gpu(device)\n\n    def reset_state(self):\n        \"\"\"Resets the internal state.\n\n        It sets None to the :attr:`c` and :attr:`h` attributes.\n\n        \"\"\"\n        self.c = self.h = None\n\n    def __call__(self, x):\n        \"\"\"Updates the internal state and returns the LSTM outputs.\n\n        Args:\n            x (~chainer.Variable): A new batch from the input sequence.\n\n        Returns:\n            ~chainer.Variable: Outputs of updated LSTM units.\n\n        \"\"\"\n        lstm_in = self.upward(x)\n        if self.h is not None:\n            lstm_in += self.lateral(self.h)\n        if self.c is None:\n            xp = self.xp\n            self.c = variable.Variable(\n                xp.zeros((len(x.data), self.state_size), dtype=x.data.dtype),\n                volatile='auto')\n        self.c, self.h = lstm.lstm(self.c, lstm_in)\n        return self.h\n", "path": "chainer/links/connection/lstm.py"}]}