We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Top-level Jacobian only works with integer argnum (not list)
This seems to be due to a bug in how we are interfacing with autograd, or -- less likely -- a bug in autograd itself.

If the user provides a quantum function `func` with multiple input arguments in its signature, we can only successfully call `qml.jacobian(func, argnum=0)`, `qml.jacobian(func, argnum=1)`, etc., but not `qml.jacobian(func, argnum=[0,1])` (raises some error inside autograd). 

Since we've coded `jacobian` to behave nicely if all the arguments are combined into an array, a suitable alternate usage is available. Would be nice to figure this bug out at some stage

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `pennylane/__init__.py`
Content:
```
1 # Copyright 2018 Xanadu Quantum Technologies Inc.
2 
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 """
15 .. _library_overview:
16 
17 Library overview
18 ================
19 
20 The PennyLane codebase contains a number of complementary components.
21 These can be roughly separated into a user-interface, supported core
22 operations, and a developer API.
23 
24 Software components
25 -------------------
26 
27 The main user-interface to PennyLane. These are the functions and
28 classes that will be used by a majority of users. For a good introduction
29 on the user-interface of PennyLane, have a look at our tutorials.
30 
31 **Basic functionality**
32 
33 * The device loader: :func:`pennylane.device`
34 * The quantum node object: :mod:`pennylane.QNode <pennylane.qnode>`
35 * The QNode decorator: :mod:`pennylane.qnode <pennylane.decorator>`
36 
37 **Extra modules**
38 
39 * Optimization methods: :mod:`pennylane.optimize`
40 * Configuration: :mod:`pennylane.Configuration <pennylane.configuration>`
41 * Utilities: :mod:`pennylane.utils <pennylane.utils>`
42 * NumPy with support for automatic differentiation: :mod:`pennylane.numpy <pennylane.numpy>`
43 
44 **Core operations**
45 
46 The main operations and observables supported by PennyLane.
47 Each of the operations supports a method
48 of computing gradients (either analytically or numerically).
49 
50 The conventions used in defining these operations are also
51 provided here.
52 
53 * Supported operations and observables: :mod:`pennylane.ops`
54 * Supported measurement types: :mod:`pennylane.measure`
55 
56 **Developer API**
57 
58 Used to develop new plugins for PennyLane - providing new devices
59 for QNodes, or supporting new operations and expectations. For more
60 details, see :ref:`developer_overview`.
61 
62 * The base Device class: :mod:`pennylane.Device <pennylane._device>`
63 * Symbolic quantum operations: :mod:`pennylane.operation`
64 * Quantum circuit parameters: :mod:`pennylane.variable`
65 
66 Summary
67 -------
68 
69 .. autosummary::
70 
71 
72     ~configuration.Configuration
73     ~_device.Device
74     ~_device.DeviceError
75     device
76     grad
77     jacobian
78     ~autograd.numpy
79     ops
80     optimize
81     ~qnode.QNode
82     ~decorator.qnode
83     ~qnode.QuantumFunctionError
84     version
85 
86 .. note::
87 
88     All individual operations and observables (contained in :mod:`~.ops`),
89     measurements (contained in :mod:`~.measure`), and optimizers
90     (contained in :mod:`~.optimize`) may also be imported directly from PennyLane.
91 
92 Code details
93 ~~~~~~~~~~~~
94 """
95 import os
96 from pkg_resources import iter_entry_points
97 
98 from autograd import numpy
99 from autograd import grad as _grad
100 from autograd import jacobian as _jacobian
101 
102 from semantic_version import Version, Spec
103 
104 import pennylane.operation
105 
106 import pennylane.init
107 import pennylane.templates.layers
108 import pennylane.templates.embeddings
109 from pennylane.about import about
110 
111 
112 from .configuration import Configuration
113 from ._device import Device, DeviceError
114 from .measure import expval, var, sample
115 from .ops import *
116 from .optimize import *
117 from .qnode import QNode, QuantumFunctionError
118 from ._version import __version__
119 
120 # NOTE: this has to be imported last,
121 # otherwise it will clash with the .qnode import.
122 from .decorator import qnode
123 
124 
125 # overwrite module docstrings
126 numpy.__doc__ = "NumPy with automatic differentiation support, provided by Autograd."
127 
128 
129 # Look for an existing configuration file
130 default_config = Configuration("config.toml")
131 
132 
133 # get list of installed plugin devices
134 plugin_devices = {entry.name: entry for entry in iter_entry_points("pennylane.plugins")}
135 
136 
137 def device(name, *args, **kwargs):
138     r"""device(name, wires=1, *args, **kwargs)
139     Load a plugin :class:`~.Device` and return the instance.
140 
141     This function is used to load a particular quantum device,
142     which can then be used to construct QNodes.
143 
144     PennyLane comes with support for the following two devices:
145 
146     * :mod:`'default.qubit' <pennylane.plugins.default_qubit>`: a simple pure
147       state simulator of qubit-based quantum circuit architectures.
148 
149     * :mod:`'default.gaussian' <pennylane.plugins.default_gaussian>`: a simple simulator
150       of Gaussian states and operations on continuous-variable circuit architectures.
151 
152     In addition, additional devices are supported through plugins — see
153     :ref:`plugins` for more details.
154 
155     All devices must be loaded by specifying their **short-name** as listed above,
156     followed by the number of *wires* (subsystems) you wish to initialize.
157 
158     Some devices may accept additional arguments. For instance,
159     ``default.gaussian`` accepts the keyword argument ``hbar``, to set
160     the convention used in the commutation relation :math:`[\x,\p]=i\hbar`
161     (by default set to 2).
162 
163     Please refer to the documentation for the individual devices to see any
164     additional arguments that might be required or supported.
165 
166     Args:
167         name (str): the name of the device to load
168         wires (int): the number of wires (subsystems) to initialise
169             the device with
170 
171     Keyword Args:
172         config (pennylane.Configuration): an PennyLane configuration object
173             that contains global and/or device specific configurations.
174     """
175     if name in plugin_devices:
176         options = {}
177 
178         # load global configuration settings if available
179         config = kwargs.get("config", default_config)
180 
181         if config:
182             # combine configuration options with keyword arguments.
183             # Keyword arguments take preference, followed by device options,
184             # followed by plugin options, followed by global options.
185             options.update(config["main"])
186             options.update(config[name.split(".")[0] + ".global"])
187             options.update(config[name])
188 
189         kwargs.pop("config", None)
190         options.update(kwargs)
191 
192         # loads the plugin device class
193         plugin_device_class = plugin_devices[name].load()
194 
195         if Version(version()) not in Spec(plugin_device_class.pennylane_requires):
196             raise DeviceError(
197                 "The {} plugin requires PennyLane versions {}, however PennyLane "
198                 "version {} is installed.".format(
199                     name, plugin_device_class.pennylane_requires, __version__
200                 )
201             )
202 
203         # load plugin device
204         return plugin_device_class(*args, **options)
205 
206     raise DeviceError(
207         "Device does not exist. Make sure the required plugin is installed."
208     )
209 
210 
211 def grad(func, argnum):
212     """Returns the gradient (as a callable function) of functions accessible within PennyLane.
213 
214     This is a wrapper around the :mod:`autograd.grad` function.
215 
216     Args:
217         func (function): a Python function or QNode that contains
218             a combination of quantum and classical nodes
219         argnum (int or list(int)): which argument(s) to take the gradient
220             with respect to
221 
222     Returns:
223         function: the function that returns the gradient of the input
224         function with respect to the arguments in argnum
225     """
226     # pylint: disable=no-value-for-parameter
227     return _grad(func, argnum)
228 
229 
230 def jacobian(func, argnum):
231     """Returns the Jacobian (as a callable function) of vector-valued
232     functions accessible within PennyLane.
233 
234     This is a wrapper around the :mod:`autograd.jacobian` function.
235 
236     Args:
237         func (function): a vector-valued Python function or QNode that contains
238             a combination of quantum and classical nodes. The output of the computation
239             must consist of a single NumPy array (if classical) or a tuple of
240             expectation values (if a quantum node)
241         argnum (int): which argument to take the gradient
242             with respect to. If the argument is a NumPy array, then the Jacobian
243             corresponding to all input elements and all output elements is returned.
244 
245     Returns:
246         function: the function that returns the Jacobian of the input
247         function with respect to the arguments in argnum
248     """
249     # pylint: disable=no-value-for-parameter
250     return _jacobian(func, argnum)
251 
252 
253 def version():
254     """Returns the PennyLane version number."""
255     return __version__
256
```
--- 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/pennylane/__init__.py b/pennylane/__init__.py
--- a/pennylane/__init__.py
+++ b/pennylane/__init__.py
@@ -238,8 +238,8 @@
             a combination of quantum and classical nodes. The output of the computation
             must consist of a single NumPy array (if classical) or a tuple of
             expectation values (if a quantum node)
-        argnum (int): which argument to take the gradient
-            with respect to. If the argument is a NumPy array, then the Jacobian
+        argnum (int or Sequence[int]): which argument to take the gradient
+            with respect to. If a sequence is given, the Jacobian matrix
             corresponding to all input elements and all output elements is returned.
 
     Returns:
@@ -247,7 +247,10 @@
         function with respect to the arguments in argnum
     """
     # pylint: disable=no-value-for-parameter
-    return _jacobian(func, argnum)
+    if isinstance(argnum, int):
+        return _jacobian(func, argnum)
+    return lambda *args, **kwargs: numpy.stack([_jacobian(func, arg)(*args, **kwargs) for arg in argnum]).T
+
 
 
 def version():

{"golden_diff": "diff --git a/pennylane/__init__.py b/pennylane/__init__.py\n--- a/pennylane/__init__.py\n+++ b/pennylane/__init__.py\n@@ -238,8 +238,8 @@\n             a combination of quantum and classical nodes. The output of the computation\n             must consist of a single NumPy array (if classical) or a tuple of\n             expectation values (if a quantum node)\n-        argnum (int): which argument to take the gradient\n-            with respect to. If the argument is a NumPy array, then the Jacobian\n+        argnum (int or Sequence[int]): which argument to take the gradient\n+            with respect to. If a sequence is given, the Jacobian matrix\n             corresponding to all input elements and all output elements is returned.\n \n     Returns:\n@@ -247,7 +247,10 @@\n         function with respect to the arguments in argnum\n     \"\"\"\n     # pylint: disable=no-value-for-parameter\n-    return _jacobian(func, argnum)\n+    if isinstance(argnum, int):\n+        return _jacobian(func, argnum)\n+    return lambda *args, **kwargs: numpy.stack([_jacobian(func, arg)(*args, **kwargs) for arg in argnum]).T\n+\n \n \n def version():\n", "issue": "Top-level Jacobian only works with integer argnum (not list)\nThis seems to be due to a bug in how we are interfacing with autograd, or -- less likely -- a bug in autograd itself.\r\n\r\nIf the user provides a quantum function `func` with multiple input arguments in its signature, we can only successfully call `qml.jacobian(func, argnum=0)`, `qml.jacobian(func, argnum=1)`, etc., but not `qml.jacobian(func, argnum=[0,1])` (raises some error inside autograd). \r\n\r\nSince we've coded `jacobian` to behave nicely if all the arguments are combined into an array, a suitable alternate usage is available. Would be nice to figure this bug out at some stage\n", "before_files": [{"content": "# Copyright 2018 Xanadu Quantum Technologies Inc.\n\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n\n#     http://www.apache.org/licenses/LICENSE-2.0\n\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\"\"\"\n.. _library_overview:\n\nLibrary overview\n================\n\nThe PennyLane codebase contains a number of complementary components.\nThese can be roughly separated into a user-interface, supported core\noperations, and a developer API.\n\nSoftware components\n-------------------\n\nThe main user-interface to PennyLane. These are the functions and\nclasses that will be used by a majority of users. For a good introduction\non the user-interface of PennyLane, have a look at our tutorials.\n\n**Basic functionality**\n\n* The device loader: :func:`pennylane.device`\n* The quantum node object: :mod:`pennylane.QNode <pennylane.qnode>`\n* The QNode decorator: :mod:`pennylane.qnode <pennylane.decorator>`\n\n**Extra modules**\n\n* Optimization methods: :mod:`pennylane.optimize`\n* Configuration: :mod:`pennylane.Configuration <pennylane.configuration>`\n* Utilities: :mod:`pennylane.utils <pennylane.utils>`\n* NumPy with support for automatic differentiation: :mod:`pennylane.numpy <pennylane.numpy>`\n\n**Core operations**\n\nThe main operations and observables supported by PennyLane.\nEach of the operations supports a method\nof computing gradients (either analytically or numerically).\n\nThe conventions used in defining these operations are also\nprovided here.\n\n* Supported operations and observables: :mod:`pennylane.ops`\n* Supported measurement types: :mod:`pennylane.measure`\n\n**Developer API**\n\nUsed to develop new plugins for PennyLane - providing new devices\nfor QNodes, or supporting new operations and expectations. For more\ndetails, see :ref:`developer_overview`.\n\n* The base Device class: :mod:`pennylane.Device <pennylane._device>`\n* Symbolic quantum operations: :mod:`pennylane.operation`\n* Quantum circuit parameters: :mod:`pennylane.variable`\n\nSummary\n-------\n\n.. autosummary::\n\n\n    ~configuration.Configuration\n    ~_device.Device\n    ~_device.DeviceError\n    device\n    grad\n    jacobian\n    ~autograd.numpy\n    ops\n    optimize\n    ~qnode.QNode\n    ~decorator.qnode\n    ~qnode.QuantumFunctionError\n    version\n\n.. note::\n\n    All individual operations and observables (contained in :mod:`~.ops`),\n    measurements (contained in :mod:`~.measure`), and optimizers\n    (contained in :mod:`~.optimize`) may also be imported directly from PennyLane.\n\nCode details\n~~~~~~~~~~~~\n\"\"\"\nimport os\nfrom pkg_resources import iter_entry_points\n\nfrom autograd import numpy\nfrom autograd import grad as _grad\nfrom autograd import jacobian as _jacobian\n\nfrom semantic_version import Version, Spec\n\nimport pennylane.operation\n\nimport pennylane.init\nimport pennylane.templates.layers\nimport pennylane.templates.embeddings\nfrom pennylane.about import about\n\n\nfrom .configuration import Configuration\nfrom ._device import Device, DeviceError\nfrom .measure import expval, var, sample\nfrom .ops import *\nfrom .optimize import *\nfrom .qnode import QNode, QuantumFunctionError\nfrom ._version import __version__\n\n# NOTE: this has to be imported last,\n# otherwise it will clash with the .qnode import.\nfrom .decorator import qnode\n\n\n# overwrite module docstrings\nnumpy.__doc__ = \"NumPy with automatic differentiation support, provided by Autograd.\"\n\n\n# Look for an existing configuration file\ndefault_config = Configuration(\"config.toml\")\n\n\n# get list of installed plugin devices\nplugin_devices = {entry.name: entry for entry in iter_entry_points(\"pennylane.plugins\")}\n\n\ndef device(name, *args, **kwargs):\n    r\"\"\"device(name, wires=1, *args, **kwargs)\n    Load a plugin :class:`~.Device` and return the instance.\n\n    This function is used to load a particular quantum device,\n    which can then be used to construct QNodes.\n\n    PennyLane comes with support for the following two devices:\n\n    * :mod:`'default.qubit' <pennylane.plugins.default_qubit>`: a simple pure\n      state simulator of qubit-based quantum circuit architectures.\n\n    * :mod:`'default.gaussian' <pennylane.plugins.default_gaussian>`: a simple simulator\n      of Gaussian states and operations on continuous-variable circuit architectures.\n\n    In addition, additional devices are supported through plugins \u2014 see\n    :ref:`plugins` for more details.\n\n    All devices must be loaded by specifying their **short-name** as listed above,\n    followed by the number of *wires* (subsystems) you wish to initialize.\n\n    Some devices may accept additional arguments. For instance,\n    ``default.gaussian`` accepts the keyword argument ``hbar``, to set\n    the convention used in the commutation relation :math:`[\\x,\\p]=i\\hbar`\n    (by default set to 2).\n\n    Please refer to the documentation for the individual devices to see any\n    additional arguments that might be required or supported.\n\n    Args:\n        name (str): the name of the device to load\n        wires (int): the number of wires (subsystems) to initialise\n            the device with\n\n    Keyword Args:\n        config (pennylane.Configuration): an PennyLane configuration object\n            that contains global and/or device specific configurations.\n    \"\"\"\n    if name in plugin_devices:\n        options = {}\n\n        # load global configuration settings if available\n        config = kwargs.get(\"config\", default_config)\n\n        if config:\n            # combine configuration options with keyword arguments.\n            # Keyword arguments take preference, followed by device options,\n            # followed by plugin options, followed by global options.\n            options.update(config[\"main\"])\n            options.update(config[name.split(\".\")[0] + \".global\"])\n            options.update(config[name])\n\n        kwargs.pop(\"config\", None)\n        options.update(kwargs)\n\n        # loads the plugin device class\n        plugin_device_class = plugin_devices[name].load()\n\n        if Version(version()) not in Spec(plugin_device_class.pennylane_requires):\n            raise DeviceError(\n                \"The {} plugin requires PennyLane versions {}, however PennyLane \"\n                \"version {} is installed.\".format(\n                    name, plugin_device_class.pennylane_requires, __version__\n                )\n            )\n\n        # load plugin device\n        return plugin_device_class(*args, **options)\n\n    raise DeviceError(\n        \"Device does not exist. Make sure the required plugin is installed.\"\n    )\n\n\ndef grad(func, argnum):\n    \"\"\"Returns the gradient (as a callable function) of functions accessible within PennyLane.\n\n    This is a wrapper around the :mod:`autograd.grad` function.\n\n    Args:\n        func (function): a Python function or QNode that contains\n            a combination of quantum and classical nodes\n        argnum (int or list(int)): which argument(s) to take the gradient\n            with respect to\n\n    Returns:\n        function: the function that returns the gradient of the input\n        function with respect to the arguments in argnum\n    \"\"\"\n    # pylint: disable=no-value-for-parameter\n    return _grad(func, argnum)\n\n\ndef jacobian(func, argnum):\n    \"\"\"Returns the Jacobian (as a callable function) of vector-valued\n    functions accessible within PennyLane.\n\n    This is a wrapper around the :mod:`autograd.jacobian` function.\n\n    Args:\n        func (function): a vector-valued Python function or QNode that contains\n            a combination of quantum and classical nodes. The output of the computation\n            must consist of a single NumPy array (if classical) or a tuple of\n            expectation values (if a quantum node)\n        argnum (int): which argument to take the gradient\n            with respect to. If the argument is a NumPy array, then the Jacobian\n            corresponding to all input elements and all output elements is returned.\n\n    Returns:\n        function: the function that returns the Jacobian of the input\n        function with respect to the arguments in argnum\n    \"\"\"\n    # pylint: disable=no-value-for-parameter\n    return _jacobian(func, argnum)\n\n\ndef version():\n    \"\"\"Returns the PennyLane version number.\"\"\"\n    return __version__\n", "path": "pennylane/__init__.py"}], "after_files": [{"content": "# Copyright 2018 Xanadu Quantum Technologies Inc.\n\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n\n#     http://www.apache.org/licenses/LICENSE-2.0\n\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\"\"\"\n.. _library_overview:\n\nLibrary overview\n================\n\nThe PennyLane codebase contains a number of complementary components.\nThese can be roughly separated into a user-interface, supported core\noperations, and a developer API.\n\nSoftware components\n-------------------\n\nThe main user-interface to PennyLane. These are the functions and\nclasses that will be used by a majority of users. For a good introduction\non the user-interface of PennyLane, have a look at our tutorials.\n\n**Basic functionality**\n\n* The device loader: :func:`pennylane.device`\n* The quantum node object: :mod:`pennylane.QNode <pennylane.qnode>`\n* The QNode decorator: :mod:`pennylane.qnode <pennylane.decorator>`\n\n**Extra modules**\n\n* Optimization methods: :mod:`pennylane.optimize`\n* Configuration: :mod:`pennylane.Configuration <pennylane.configuration>`\n* Utilities: :mod:`pennylane.utils <pennylane.utils>`\n* NumPy with support for automatic differentiation: :mod:`pennylane.numpy <pennylane.numpy>`\n\n**Core operations**\n\nThe main operations and observables supported by PennyLane.\nEach of the operations supports a method\nof computing gradients (either analytically or numerically).\n\nThe conventions used in defining these operations are also\nprovided here.\n\n* Supported operations and observables: :mod:`pennylane.ops`\n* Supported measurement types: :mod:`pennylane.measure`\n\n**Developer API**\n\nUsed to develop new plugins for PennyLane - providing new devices\nfor QNodes, or supporting new operations and expectations. For more\ndetails, see :ref:`developer_overview`.\n\n* The base Device class: :mod:`pennylane.Device <pennylane._device>`\n* Symbolic quantum operations: :mod:`pennylane.operation`\n* Quantum circuit parameters: :mod:`pennylane.variable`\n\nSummary\n-------\n\n.. autosummary::\n\n\n    ~configuration.Configuration\n    ~_device.Device\n    ~_device.DeviceError\n    device\n    grad\n    jacobian\n    ~autograd.numpy\n    ops\n    optimize\n    ~qnode.QNode\n    ~decorator.qnode\n    ~qnode.QuantumFunctionError\n    version\n\n.. note::\n\n    All individual operations and observables (contained in :mod:`~.ops`),\n    measurements (contained in :mod:`~.measure`), and optimizers\n    (contained in :mod:`~.optimize`) may also be imported directly from PennyLane.\n\nCode details\n~~~~~~~~~~~~\n\"\"\"\nimport os\nfrom pkg_resources import iter_entry_points\n\nfrom autograd import numpy\nfrom autograd import grad as _grad\nfrom autograd import jacobian as _jacobian\n\nfrom semantic_version import Version, Spec\n\nimport pennylane.operation\n\nimport pennylane.init\nimport pennylane.templates.layers\nimport pennylane.templates.embeddings\nfrom pennylane.about import about\n\n\nfrom .configuration import Configuration\nfrom ._device import Device, DeviceError\nfrom .measure import expval, var, sample\nfrom .ops import *\nfrom .optimize import *\nfrom .qnode import QNode, QuantumFunctionError\nfrom ._version import __version__\n\n# NOTE: this has to be imported last,\n# otherwise it will clash with the .qnode import.\nfrom .decorator import qnode\n\n\n# overwrite module docstrings\nnumpy.__doc__ = \"NumPy with automatic differentiation support, provided by Autograd.\"\n\n\n# Look for an existing configuration file\ndefault_config = Configuration(\"config.toml\")\n\n\n# get list of installed plugin devices\nplugin_devices = {entry.name: entry for entry in iter_entry_points(\"pennylane.plugins\")}\n\n\ndef device(name, *args, **kwargs):\n    r\"\"\"device(name, wires=1, *args, **kwargs)\n    Load a plugin :class:`~.Device` and return the instance.\n\n    This function is used to load a particular quantum device,\n    which can then be used to construct QNodes.\n\n    PennyLane comes with support for the following two devices:\n\n    * :mod:`'default.qubit' <pennylane.plugins.default_qubit>`: a simple pure\n      state simulator of qubit-based quantum circuit architectures.\n\n    * :mod:`'default.gaussian' <pennylane.plugins.default_gaussian>`: a simple simulator\n      of Gaussian states and operations on continuous-variable circuit architectures.\n\n    In addition, additional devices are supported through plugins \u2014 see\n    :ref:`plugins` for more details.\n\n    All devices must be loaded by specifying their **short-name** as listed above,\n    followed by the number of *wires* (subsystems) you wish to initialize.\n\n    Some devices may accept additional arguments. For instance,\n    ``default.gaussian`` accepts the keyword argument ``hbar``, to set\n    the convention used in the commutation relation :math:`[\\x,\\p]=i\\hbar`\n    (by default set to 2).\n\n    Please refer to the documentation for the individual devices to see any\n    additional arguments that might be required or supported.\n\n    Args:\n        name (str): the name of the device to load\n        wires (int): the number of wires (subsystems) to initialise\n            the device with\n\n    Keyword Args:\n        config (pennylane.Configuration): an PennyLane configuration object\n            that contains global and/or device specific configurations.\n    \"\"\"\n    if name in plugin_devices:\n        options = {}\n\n        # load global configuration settings if available\n        config = kwargs.get(\"config\", default_config)\n\n        if config:\n            # combine configuration options with keyword arguments.\n            # Keyword arguments take preference, followed by device options,\n            # followed by plugin options, followed by global options.\n            options.update(config[\"main\"])\n            options.update(config[name.split(\".\")[0] + \".global\"])\n            options.update(config[name])\n\n        kwargs.pop(\"config\", None)\n        options.update(kwargs)\n\n        # loads the plugin device class\n        plugin_device_class = plugin_devices[name].load()\n\n        if Version(version()) not in Spec(plugin_device_class.pennylane_requires):\n            raise DeviceError(\n                \"The {} plugin requires PennyLane versions {}, however PennyLane \"\n                \"version {} is installed.\".format(\n                    name, plugin_device_class.pennylane_requires, __version__\n                )\n            )\n\n        # load plugin device\n        return plugin_device_class(*args, **options)\n\n    raise DeviceError(\n        \"Device does not exist. Make sure the required plugin is installed.\"\n    )\n\n\ndef grad(func, argnum):\n    \"\"\"Returns the gradient (as a callable function) of functions accessible within PennyLane.\n\n    This is a wrapper around the :mod:`autograd.grad` function.\n\n    Args:\n        func (function): a Python function or QNode that contains\n            a combination of quantum and classical nodes\n        argnum (int or list(int)): which argument(s) to take the gradient\n            with respect to\n\n    Returns:\n        function: the function that returns the gradient of the input\n        function with respect to the arguments in argnum\n    \"\"\"\n    # pylint: disable=no-value-for-parameter\n    return _grad(func, argnum)\n\n\ndef jacobian(func, argnum):\n    \"\"\"Returns the Jacobian (as a callable function) of vector-valued\n    functions accessible within PennyLane.\n\n    This is a wrapper around the :mod:`autograd.jacobian` function.\n\n    Args:\n        func (function): a vector-valued Python function or QNode that contains\n            a combination of quantum and classical nodes. The output of the computation\n            must consist of a single NumPy array (if classical) or a tuple of\n            expectation values (if a quantum node)\n        argnum (int or Sequence[int]): which argument to take the gradient\n            with respect to. If a sequence is given, the Jacobian matrix\n            corresponding to all input elements and all output elements is returned.\n\n    Returns:\n        function: the function that returns the Jacobian of the input\n        function with respect to the arguments in argnum\n    \"\"\"\n    # pylint: disable=no-value-for-parameter\n    if isinstance(argnum, int):\n        return _jacobian(func, argnum)\n    return lambda *args, **kwargs: numpy.stack([_jacobian(func, arg)(*args, **kwargs) for arg in argnum]).T\n\n\n\ndef version():\n    \"\"\"Returns the PennyLane version number.\"\"\"\n    return __version__\n", "path": "pennylane/__init__.py"}]}