prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  FunctionSet.copy_parameters_from()
  Hi all!
  
  The code in 'FunctionSet.copy_parameters_from()' does not work, when 'src' and 'dst' are both numpy.ndarrays?
  
  ``` python
  if isinstance(dst, numpy.ndarray):
      if isinstance(src, numpy.ndarray):
          dst.copy(src)  # this gives a ValueError
  ```
  
  I think this should read
  
  ``` python
  if isinstance(dst, numpy.ndarray):
      if isinstance(src, numpy.ndarray):
          numpy.copyto(dst, src)
  ```
  
  My numpy.version.full_version is 1.9.2, the 'copyto' method exists since 1.7.0.
  
  Cheers,
  -r
  
  
  --- 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/function_set.py`
  Content:
  ```
  1 import numpy
  2 import six
  3 
  4 from chainer import cuda
  5 
  6 
  7 class FunctionSet(object):
  8 
  9     """Set of objects with ``parameters`` and ``gradients`` properties.
  10 
  11     :class:`FunctionSet` is useful to collect parameters and gradients of
  12     multiple parameterized :class:`Function` objects. :class:`FunctionSet`
  13     itself also implements :attr:`~FunctionSet.parameters` and
  14     :attr:`~FunctionSet.gradients`, so it can be nested in another
  15     :class:`FunctionSet` object.
  16 
  17     Function registration is done by just adding an attribute to
  18     :class:`FunctionSet` object.
  19 
  20     """
  21 
  22     def __init__(self, **functions):
  23         """Initializes the function set by given functions.
  24 
  25         Args:
  26             **functions: ``dict`` of ``str`` key and :class:`Function` values.
  27                 The key-value pairs are just set to the :class:`FunctionSet`
  28                 object as attributes.
  29 
  30         """
  31         for name, func in six.iteritems(functions):
  32             setattr(self, name, func)
  33 
  34     def collect_parameters(self):
  35         """Returns a tuple of parameters and gradients.
  36 
  37         Returns:
  38             Tuple (pair) of two tuples. The first element is a tuple of
  39             parameter arrays, and the second is a tuple of gradient arrays.
  40 
  41         """
  42         return self.parameters, self.gradients
  43 
  44     def to_gpu(self, device=None):
  45         """Migrates all parameters and gradients onto GPU.
  46 
  47         This method calls ``to_gpu`` method of each registered object.
  48 
  49         Args:
  50             device (int or :class:`pycuda.driver.Device` or ``None``): Device
  51                 ID of GPU. If ``None`` is given, it uses the current device.
  52 
  53         Returns:
  54             self
  55 
  56         """
  57         for func in six.itervalues(self.__dict__):
  58             func.to_gpu(device=device)
  59         return self
  60 
  61     def to_cpu(self):
  62         """Migrates all parameters and gradients onto CPU.
  63 
  64         This method calls ``to_cpu`` method of each registered object.
  65 
  66         Returns:
  67             self
  68 
  69         """
  70         for func in six.itervalues(self.__dict__):
  71             func.to_cpu()
  72         return self
  73 
  74     def copy_parameters_from(self, params):
  75         """Copies parameters from another source without reallocation.
  76 
  77         Args:
  78             params (Iterable): Iterable of parameter arrays.
  79 
  80         """
  81         for dst, src in zip(self.parameters, params):
  82             if isinstance(dst, numpy.ndarray):
  83                 if isinstance(src, numpy.ndarray):
  84                     dst.copy(src)
  85                 else:
  86                     src.get(dst)
  87             elif isinstance(src, numpy.ndarray):
  88                 dst.set(src)
  89             else:
  90                 cuda.copy(src, out=dst)
  91 
  92     @property
  93     def parameters(self):
  94         """Tuple of parameter arrays of all registered functions.
  95 
  96         The order of parameters is consistent with :meth:`gradients` property.
  97 
  98         """
  99         return sum((func.parameters for _, func in self._get_sorted_funcs()),
  100                    ())
  101 
  102     @parameters.setter
  103     def parameters(self, params):
  104         param_iter = iter(params)
  105         for _, func in self._get_sorted_funcs():
  106             func.parameters = param_iter
  107 
  108     @property
  109     def gradients(self):
  110         """Tuple of gradient arrays of all registered functions.
  111 
  112         The order of gradients is consistent with :meth:`parameters` property.
  113 
  114         """
  115         return sum((func.gradients for _, func in self._get_sorted_funcs()),
  116                    ())
  117 
  118     @gradients.setter
  119     def gradients(self, grads):
  120         grad_iter = iter(grads)
  121         for _, func in self._get_sorted_funcs():
  122             func.gradients = grad_iter
  123 
  124     def _get_sorted_funcs(self):
  125         return sorted(six.iteritems(self.__dict__))
  126
  ```
  --- 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()
  
  ```
  
golden_diff: diff --git a/chainer/function_set.py b/chainer/function_set.py
  --- a/chainer/function_set.py
  +++ b/chainer/function_set.py
  @@ -81,7 +81,7 @@
           for dst, src in zip(self.parameters, params):
               if isinstance(dst, numpy.ndarray):
                   if isinstance(src, numpy.ndarray):
  -                    dst.copy(src)
  +                    numpy.copyto(dst, src)
                   else:
                       src.get(dst)
               elif isinstance(src, numpy.ndarray):
  
verification_info: {"golden_diff": "diff --git a/chainer/function_set.py b/chainer/function_set.py\n--- a/chainer/function_set.py\n+++ b/chainer/function_set.py\n@@ -81,7 +81,7 @@\n         for dst, src in zip(self.parameters, params):\n             if isinstance(dst, numpy.ndarray):\n                 if isinstance(src, numpy.ndarray):\n-                    dst.copy(src)\n+                    numpy.copyto(dst, src)\n                 else:\n                     src.get(dst)\n             elif isinstance(src, numpy.ndarray):\n", "issue": "FunctionSet.copy_parameters_from()\nHi all!\n\nThe code in 'FunctionSet.copy_parameters_from()' does not work, when 'src' and 'dst' are both numpy.ndarrays?\n\n``` python\nif isinstance(dst, numpy.ndarray):\n    if isinstance(src, numpy.ndarray):\n        dst.copy(src)  # this gives a ValueError\n```\n\nI think this should read\n\n``` python\nif isinstance(dst, numpy.ndarray):\n    if isinstance(src, numpy.ndarray):\n        numpy.copyto(dst, src)\n```\n\nMy numpy.version.full_version is 1.9.2, the 'copyto' method exists since 1.7.0.\n\nCheers,\n-r\n\n", "before_files": [{"content": "import numpy\nimport six\n\nfrom chainer import cuda\n\n\nclass FunctionSet(object):\n\n    \"\"\"Set of objects with ``parameters`` and ``gradients`` properties.\n\n    :class:`FunctionSet` is useful to collect parameters and gradients of\n    multiple parameterized :class:`Function` objects. :class:`FunctionSet`\n    itself also implements :attr:`~FunctionSet.parameters` and\n    :attr:`~FunctionSet.gradients`, so it can be nested in another\n    :class:`FunctionSet` object.\n\n    Function registration is done by just adding an attribute to\n    :class:`FunctionSet` object.\n\n    \"\"\"\n\n    def __init__(self, **functions):\n        \"\"\"Initializes the function set by given functions.\n\n        Args:\n            **functions: ``dict`` of ``str`` key and :class:`Function` values.\n                The key-value pairs are just set to the :class:`FunctionSet`\n                object as attributes.\n\n        \"\"\"\n        for name, func in six.iteritems(functions):\n            setattr(self, name, func)\n\n    def collect_parameters(self):\n        \"\"\"Returns a tuple of parameters and gradients.\n\n        Returns:\n            Tuple (pair) of two tuples. The first element is a tuple of\n            parameter arrays, and the second is a tuple of gradient arrays.\n\n        \"\"\"\n        return self.parameters, self.gradients\n\n    def to_gpu(self, device=None):\n        \"\"\"Migrates all parameters and gradients onto GPU.\n\n        This method calls ``to_gpu`` method of each registered object.\n\n        Args:\n            device (int or :class:`pycuda.driver.Device` or ``None``): Device\n                ID of GPU. If ``None`` is given, it uses the current device.\n\n        Returns:\n            self\n\n        \"\"\"\n        for func in six.itervalues(self.__dict__):\n            func.to_gpu(device=device)\n        return self\n\n    def to_cpu(self):\n        \"\"\"Migrates all parameters and gradients onto CPU.\n\n        This method calls ``to_cpu`` method of each registered object.\n\n        Returns:\n            self\n\n        \"\"\"\n        for func in six.itervalues(self.__dict__):\n            func.to_cpu()\n        return self\n\n    def copy_parameters_from(self, params):\n        \"\"\"Copies parameters from another source without reallocation.\n\n        Args:\n            params (Iterable): Iterable of parameter arrays.\n\n        \"\"\"\n        for dst, src in zip(self.parameters, params):\n            if isinstance(dst, numpy.ndarray):\n                if isinstance(src, numpy.ndarray):\n                    dst.copy(src)\n                else:\n                    src.get(dst)\n            elif isinstance(src, numpy.ndarray):\n                dst.set(src)\n            else:\n                cuda.copy(src, out=dst)\n\n    @property\n    def parameters(self):\n        \"\"\"Tuple of parameter arrays of all registered functions.\n\n        The order of parameters is consistent with :meth:`gradients` property.\n\n        \"\"\"\n        return sum((func.parameters for _, func in self._get_sorted_funcs()),\n                   ())\n\n    @parameters.setter\n    def parameters(self, params):\n        param_iter = iter(params)\n        for _, func in self._get_sorted_funcs():\n            func.parameters = param_iter\n\n    @property\n    def gradients(self):\n        \"\"\"Tuple of gradient arrays of all registered functions.\n\n        The order of gradients is consistent with :meth:`parameters` property.\n\n        \"\"\"\n        return sum((func.gradients for _, func in self._get_sorted_funcs()),\n                   ())\n\n    @gradients.setter\n    def gradients(self, grads):\n        grad_iter = iter(grads)\n        for _, func in self._get_sorted_funcs():\n            func.gradients = grad_iter\n\n    def _get_sorted_funcs(self):\n        return sorted(six.iteritems(self.__dict__))\n", "path": "chainer/function_set.py"}], "after_files": [{"content": "import numpy\nimport six\n\nfrom chainer import cuda\n\n\nclass FunctionSet(object):\n\n    \"\"\"Set of objects with ``parameters`` and ``gradients`` properties.\n\n    :class:`FunctionSet` is useful to collect parameters and gradients of\n    multiple parameterized :class:`Function` objects. :class:`FunctionSet`\n    itself also implements :attr:`~FunctionSet.parameters` and\n    :attr:`~FunctionSet.gradients`, so it can be nested in another\n    :class:`FunctionSet` object.\n\n    Function registration is done by just adding an attribute to\n    :class:`FunctionSet` object.\n\n    \"\"\"\n\n    def __init__(self, **functions):\n        \"\"\"Initializes the function set by given functions.\n\n        Args:\n            **functions: ``dict`` of ``str`` key and :class:`Function` values.\n                The key-value pairs are just set to the :class:`FunctionSet`\n                object as attributes.\n\n        \"\"\"\n        for name, func in six.iteritems(functions):\n            setattr(self, name, func)\n\n    def collect_parameters(self):\n        \"\"\"Returns a tuple of parameters and gradients.\n\n        Returns:\n            Tuple (pair) of two tuples. The first element is a tuple of\n            parameter arrays, and the second is a tuple of gradient arrays.\n\n        \"\"\"\n        return self.parameters, self.gradients\n\n    def to_gpu(self, device=None):\n        \"\"\"Migrates all parameters and gradients onto GPU.\n\n        This method calls ``to_gpu`` method of each registered object.\n\n        Args:\n            device (int or :class:`pycuda.driver.Device` or ``None``): Device\n                ID of GPU. If ``None`` is given, it uses the current device.\n\n        Returns:\n            self\n\n        \"\"\"\n        for func in six.itervalues(self.__dict__):\n            func.to_gpu(device=device)\n        return self\n\n    def to_cpu(self):\n        \"\"\"Migrates all parameters and gradients onto CPU.\n\n        This method calls ``to_cpu`` method of each registered object.\n\n        Returns:\n            self\n\n        \"\"\"\n        for func in six.itervalues(self.__dict__):\n            func.to_cpu()\n        return self\n\n    def copy_parameters_from(self, params):\n        \"\"\"Copies parameters from another source without reallocation.\n\n        Args:\n            params (Iterable): Iterable of parameter arrays.\n\n        \"\"\"\n        for dst, src in zip(self.parameters, params):\n            if isinstance(dst, numpy.ndarray):\n                if isinstance(src, numpy.ndarray):\n                    numpy.copyto(dst, src)\n                else:\n                    src.get(dst)\n            elif isinstance(src, numpy.ndarray):\n                dst.set(src)\n            else:\n                cuda.copy(src, out=dst)\n\n    @property\n    def parameters(self):\n        \"\"\"Tuple of parameter arrays of all registered functions.\n\n        The order of parameters is consistent with :meth:`gradients` property.\n\n        \"\"\"\n        return sum((func.parameters for _, func in self._get_sorted_funcs()),\n                   ())\n\n    @parameters.setter\n    def parameters(self, params):\n        param_iter = iter(params)\n        for _, func in self._get_sorted_funcs():\n            func.parameters = param_iter\n\n    @property\n    def gradients(self):\n        \"\"\"Tuple of gradient arrays of all registered functions.\n\n        The order of gradients is consistent with :meth:`parameters` property.\n\n        \"\"\"\n        return sum((func.gradients for _, func in self._get_sorted_funcs()),\n                   ())\n\n    @gradients.setter\n    def gradients(self, grads):\n        grad_iter = iter(grads)\n        for _, func in self._get_sorted_funcs():\n            func.gradients = grad_iter\n\n    def _get_sorted_funcs(self):\n        return sorted(six.iteritems(self.__dict__))\n", "path": "chainer/function_set.py"}]}