prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Raise exception or warning when `qml.adjoint` is used on operation list instead of function.
  The newer `qml.adjoint` function does not have any effect when acting on operation lists like in the following example:
  ```python
  params = list(range(4))
  qml.adjoint(qml.templates.AngleEmbedding(params))
  ```
  Users might try this, because it worked like this with `qml.inv` which `qml.adjoint` is replacing. Therefore, we should raise
  an exception whenever this is attempted by checking for the input to be `callable`. Alternatively, a warning could be raised, but 
  the behaviour differs fundamentally from the expected, an exception seems more appropriate.
  
  
  
  --- 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/transforms/adjoint.py`
  Content:
  ```
  1 # Copyright 2018-2021 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 """Code for the adjoint transform."""
  15 
  16 from functools import wraps
  17 from pennylane.tape import QuantumTape, stop_recording
  18 
  19 
  20 def adjoint(fn):
  21     """Create a function that applies the adjoint (inverse) of the provided operation or template.
  22 
  23     This transform can be used to apply the adjoint of an arbitrary sequence of operations.
  24 
  25     Args:
  26         fn (function): A quantum function that applies quantum operations.
  27 
  28     Returns:
  29         function: A new function that will apply the same operations but adjointed and in reverse order.
  30 
  31     **Example**
  32 
  33     The adjoint transforms can be used within a QNode to apply the adjoint of
  34     any quantum function. Consider the following quantum function, that applies two
  35     operations:
  36 
  37     .. code-block:: python3
  38 
  39         def my_ops(a, b, wire):
  40             qml.RX(a, wires=wire)
  41             qml.RY(b, wires=wire)
  42 
  43     We can create a QNode that applies this quantum function,
  44     followed by the adjoint of this function:
  45 
  46     .. code-block:: python3
  47 
  48         dev = qml.device('default.qubit', wires=1)
  49 
  50         @qml.qnode(dev)
  51         def circuit(a, b):
  52             my_ops(a, b, wire=0)
  53             qml.adjoint(my_ops)(a, b, wire=0)
  54             return qml.expval(qml.PauliZ(0))
  55 
  56     Printing this out, we can see that the inverse quantum
  57     function has indeed been applied:
  58 
  59     >>> print(qml.draw(circuit)(0.2, 0.5))
  60      0: ──RX(0.2)──RY(0.5)──RY(-0.5)──RX(-0.2)──┤ ⟨Z⟩
  61 
  62     The adjoint function can also be applied directly to templates and operations:
  63 
  64     >>> qml.adjoint(qml.RX)(0.123, wires=0)
  65     >>> qml.adjoint(qml.templates.StronglyEntanglingLayers)(weights, wires=[0, 1])
  66 
  67     .. UsageDetails::
  68 
  69         **Adjoint of a function**
  70 
  71         Here, we apply the ``subroutine`` function, and then apply its inverse.
  72         Notice that in addition to adjointing all of the operations, they are also
  73         applied in reverse construction order.
  74 
  75         .. code-block:: python3
  76 
  77             def subroutine(wire):
  78                 qml.RX(0.123, wires=wire)
  79                 qml.RY(0.456, wires=wire)
  80 
  81             dev = qml.device('default.qubit', wires=1)
  82             @qml.qnode(dev)
  83             def circuit():
  84                 subroutine(0)
  85                 qml.adjoint(subroutine)(0)
  86                 return qml.expval(qml.PauliZ(0))
  87 
  88         This creates the following circuit:
  89 
  90         >>> print(qml.draw(circuit)())
  91         0: --RX(0.123)--RY(0.456)--RY(-0.456)--RX(-0.123)--| <Z>
  92 
  93         **Single operation**
  94 
  95         You can also easily adjoint a single operation just by wrapping it with ``adjoint``:
  96 
  97         .. code-block:: python3
  98 
  99             dev = qml.device('default.qubit', wires=1)
  100             @qml.qnode(dev)
  101             def circuit():
  102                 qml.RX(0.123, wires=0)
  103                 qml.adjoint(qml.RX)(0.123, wires=0)
  104                 return qml.expval(qml.PauliZ(0))
  105 
  106         This creates the following circuit:
  107 
  108         >>> print(qml.draw(circuit)())
  109         0: --RX(0.123)--RX(-0.123)--| <Z>
  110     """
  111 
  112     @wraps(fn)
  113     def wrapper(*args, **kwargs):
  114         with stop_recording(), QuantumTape() as tape:
  115             fn(*args, **kwargs)
  116 
  117         if not tape.operations:
  118             # we called op.expand(): get the outputted tape
  119             tape = fn(*args, **kwargs)
  120 
  121         adjoint_ops = []
  122         for op in reversed(tape.operations):
  123             try:
  124                 new_op = op.adjoint()
  125                 adjoint_ops.append(new_op)
  126             except NotImplementedError:
  127                 # Expand the operation and adjoint the result.
  128                 new_ops = adjoint(op.expand)()
  129 
  130                 if isinstance(new_ops, QuantumTape):
  131                     new_ops = new_ops.operations
  132 
  133                 adjoint_ops.extend(new_ops)
  134 
  135         if len(adjoint_ops) == 1:
  136             adjoint_ops = adjoint_ops[0]
  137 
  138         return adjoint_ops
  139 
  140     return wrapper
  141
  ```
  --- 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/pennylane/transforms/adjoint.py b/pennylane/transforms/adjoint.py
  --- a/pennylane/transforms/adjoint.py
  +++ b/pennylane/transforms/adjoint.py
  @@ -108,6 +108,12 @@
           >>> print(qml.draw(circuit)())
           0: --RX(0.123)--RX(-0.123)--| <Z>
       """
  +    if not callable(fn):
  +        raise ValueError(
  +            f"The object {fn} of type {type(fn)} is not callable. "
  +            "This error might occur if you apply adjoint to a list "
  +            "of operations instead of a function or template."
  +        )
   
       @wraps(fn)
       def wrapper(*args, **kwargs):
  
verification_info: {"golden_diff": "diff --git a/pennylane/transforms/adjoint.py b/pennylane/transforms/adjoint.py\n--- a/pennylane/transforms/adjoint.py\n+++ b/pennylane/transforms/adjoint.py\n@@ -108,6 +108,12 @@\n         >>> print(qml.draw(circuit)())\r\n         0: --RX(0.123)--RX(-0.123)--| <Z>\r\n     \"\"\"\r\n+    if not callable(fn):\r\n+        raise ValueError(\r\n+            f\"The object {fn} of type {type(fn)} is not callable. \"\r\n+            \"This error might occur if you apply adjoint to a list \"\r\n+            \"of operations instead of a function or template.\"\r\n+        )\r\n \r\n     @wraps(fn)\r\n     def wrapper(*args, **kwargs):\n", "issue": "Raise exception or warning when `qml.adjoint` is used on operation list instead of function.\nThe newer `qml.adjoint` function does not have any effect when acting on operation lists like in the following example:\r\n```python\r\nparams = list(range(4))\r\nqml.adjoint(qml.templates.AngleEmbedding(params))\r\n```\r\nUsers might try this, because it worked like this with `qml.inv` which `qml.adjoint` is replacing. Therefore, we should raise\r\nan exception whenever this is attempted by checking for the input to be `callable`. Alternatively, a warning could be raised, but \r\nthe behaviour differs fundamentally from the expected, an exception seems more appropriate.\r\n\r\n\n", "before_files": [{"content": "# Copyright 2018-2021 Xanadu Quantum Technologies Inc.\r\n\r\n# Licensed under the Apache License, Version 2.0 (the \"License\");\r\n# you may not use this file except in compliance with the License.\r\n# You may obtain a copy of the License at\r\n\r\n#     http://www.apache.org/licenses/LICENSE-2.0\r\n\r\n# Unless required by applicable law or agreed to in writing, software\r\n# distributed under the License is distributed on an \"AS IS\" BASIS,\r\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n# See the License for the specific language governing permissions and\r\n# limitations under the License.\r\n\"\"\"Code for the adjoint transform.\"\"\"\r\n\r\nfrom functools import wraps\r\nfrom pennylane.tape import QuantumTape, stop_recording\r\n\r\n\r\ndef adjoint(fn):\r\n    \"\"\"Create a function that applies the adjoint (inverse) of the provided operation or template.\r\n\r\n    This transform can be used to apply the adjoint of an arbitrary sequence of operations.\r\n\r\n    Args:\r\n        fn (function): A quantum function that applies quantum operations.\r\n\r\n    Returns:\r\n        function: A new function that will apply the same operations but adjointed and in reverse order.\r\n\r\n    **Example**\r\n\r\n    The adjoint transforms can be used within a QNode to apply the adjoint of\r\n    any quantum function. Consider the following quantum function, that applies two\r\n    operations:\r\n\r\n    .. code-block:: python3\r\n\r\n        def my_ops(a, b, wire):\r\n            qml.RX(a, wires=wire)\r\n            qml.RY(b, wires=wire)\r\n\r\n    We can create a QNode that applies this quantum function,\r\n    followed by the adjoint of this function:\r\n\r\n    .. code-block:: python3\r\n\r\n        dev = qml.device('default.qubit', wires=1)\r\n\r\n        @qml.qnode(dev)\r\n        def circuit(a, b):\r\n            my_ops(a, b, wire=0)\r\n            qml.adjoint(my_ops)(a, b, wire=0)\r\n            return qml.expval(qml.PauliZ(0))\r\n\r\n    Printing this out, we can see that the inverse quantum\r\n    function has indeed been applied:\r\n\r\n    >>> print(qml.draw(circuit)(0.2, 0.5))\r\n     0: \u2500\u2500RX(0.2)\u2500\u2500RY(0.5)\u2500\u2500RY(-0.5)\u2500\u2500RX(-0.2)\u2500\u2500\u2524 \u27e8Z\u27e9\r\n\r\n    The adjoint function can also be applied directly to templates and operations:\r\n\r\n    >>> qml.adjoint(qml.RX)(0.123, wires=0)\r\n    >>> qml.adjoint(qml.templates.StronglyEntanglingLayers)(weights, wires=[0, 1])\r\n\r\n    .. UsageDetails::\r\n\r\n        **Adjoint of a function**\r\n\r\n        Here, we apply the ``subroutine`` function, and then apply its inverse.\r\n        Notice that in addition to adjointing all of the operations, they are also\r\n        applied in reverse construction order.\r\n\r\n        .. code-block:: python3\r\n\r\n            def subroutine(wire):\r\n                qml.RX(0.123, wires=wire)\r\n                qml.RY(0.456, wires=wire)\r\n\r\n            dev = qml.device('default.qubit', wires=1)\r\n            @qml.qnode(dev)\r\n            def circuit():\r\n                subroutine(0)\r\n                qml.adjoint(subroutine)(0)\r\n                return qml.expval(qml.PauliZ(0))\r\n\r\n        This creates the following circuit:\r\n\r\n        >>> print(qml.draw(circuit)())\r\n        0: --RX(0.123)--RY(0.456)--RY(-0.456)--RX(-0.123)--| <Z>\r\n\r\n        **Single operation**\r\n\r\n        You can also easily adjoint a single operation just by wrapping it with ``adjoint``:\r\n\r\n        .. code-block:: python3\r\n\r\n            dev = qml.device('default.qubit', wires=1)\r\n            @qml.qnode(dev)\r\n            def circuit():\r\n                qml.RX(0.123, wires=0)\r\n                qml.adjoint(qml.RX)(0.123, wires=0)\r\n                return qml.expval(qml.PauliZ(0))\r\n\r\n        This creates the following circuit:\r\n\r\n        >>> print(qml.draw(circuit)())\r\n        0: --RX(0.123)--RX(-0.123)--| <Z>\r\n    \"\"\"\r\n\r\n    @wraps(fn)\r\n    def wrapper(*args, **kwargs):\r\n        with stop_recording(), QuantumTape() as tape:\r\n            fn(*args, **kwargs)\r\n\r\n        if not tape.operations:\r\n            # we called op.expand(): get the outputted tape\r\n            tape = fn(*args, **kwargs)\r\n\r\n        adjoint_ops = []\r\n        for op in reversed(tape.operations):\r\n            try:\r\n                new_op = op.adjoint()\r\n                adjoint_ops.append(new_op)\r\n            except NotImplementedError:\r\n                # Expand the operation and adjoint the result.\r\n                new_ops = adjoint(op.expand)()\r\n\r\n                if isinstance(new_ops, QuantumTape):\r\n                    new_ops = new_ops.operations\r\n\r\n                adjoint_ops.extend(new_ops)\r\n\r\n        if len(adjoint_ops) == 1:\r\n            adjoint_ops = adjoint_ops[0]\r\n\r\n        return adjoint_ops\r\n\r\n    return wrapper\r\n", "path": "pennylane/transforms/adjoint.py"}], "after_files": [{"content": "# Copyright 2018-2021 Xanadu Quantum Technologies Inc.\r\n\r\n# Licensed under the Apache License, Version 2.0 (the \"License\");\r\n# you may not use this file except in compliance with the License.\r\n# You may obtain a copy of the License at\r\n\r\n#     http://www.apache.org/licenses/LICENSE-2.0\r\n\r\n# Unless required by applicable law or agreed to in writing, software\r\n# distributed under the License is distributed on an \"AS IS\" BASIS,\r\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n# See the License for the specific language governing permissions and\r\n# limitations under the License.\r\n\"\"\"Code for the adjoint transform.\"\"\"\r\n\r\nfrom functools import wraps\r\nfrom pennylane.tape import QuantumTape, stop_recording\r\n\r\n\r\ndef adjoint(fn):\r\n    \"\"\"Create a function that applies the adjoint (inverse) of the provided operation or template.\r\n\r\n    This transform can be used to apply the adjoint of an arbitrary sequence of operations.\r\n\r\n    Args:\r\n        fn (function): A quantum function that applies quantum operations.\r\n\r\n    Returns:\r\n        function: A new function that will apply the same operations but adjointed and in reverse order.\r\n\r\n    **Example**\r\n\r\n    The adjoint transforms can be used within a QNode to apply the adjoint of\r\n    any quantum function. Consider the following quantum function, that applies two\r\n    operations:\r\n\r\n    .. code-block:: python3\r\n\r\n        def my_ops(a, b, wire):\r\n            qml.RX(a, wires=wire)\r\n            qml.RY(b, wires=wire)\r\n\r\n    We can create a QNode that applies this quantum function,\r\n    followed by the adjoint of this function:\r\n\r\n    .. code-block:: python3\r\n\r\n        dev = qml.device('default.qubit', wires=1)\r\n\r\n        @qml.qnode(dev)\r\n        def circuit(a, b):\r\n            my_ops(a, b, wire=0)\r\n            qml.adjoint(my_ops)(a, b, wire=0)\r\n            return qml.expval(qml.PauliZ(0))\r\n\r\n    Printing this out, we can see that the inverse quantum\r\n    function has indeed been applied:\r\n\r\n    >>> print(qml.draw(circuit)(0.2, 0.5))\r\n     0: \u2500\u2500RX(0.2)\u2500\u2500RY(0.5)\u2500\u2500RY(-0.5)\u2500\u2500RX(-0.2)\u2500\u2500\u2524 \u27e8Z\u27e9\r\n\r\n    The adjoint function can also be applied directly to templates and operations:\r\n\r\n    >>> qml.adjoint(qml.RX)(0.123, wires=0)\r\n    >>> qml.adjoint(qml.templates.StronglyEntanglingLayers)(weights, wires=[0, 1])\r\n\r\n    .. UsageDetails::\r\n\r\n        **Adjoint of a function**\r\n\r\n        Here, we apply the ``subroutine`` function, and then apply its inverse.\r\n        Notice that in addition to adjointing all of the operations, they are also\r\n        applied in reverse construction order.\r\n\r\n        .. code-block:: python3\r\n\r\n            def subroutine(wire):\r\n                qml.RX(0.123, wires=wire)\r\n                qml.RY(0.456, wires=wire)\r\n\r\n            dev = qml.device('default.qubit', wires=1)\r\n            @qml.qnode(dev)\r\n            def circuit():\r\n                subroutine(0)\r\n                qml.adjoint(subroutine)(0)\r\n                return qml.expval(qml.PauliZ(0))\r\n\r\n        This creates the following circuit:\r\n\r\n        >>> print(qml.draw(circuit)())\r\n        0: --RX(0.123)--RY(0.456)--RY(-0.456)--RX(-0.123)--| <Z>\r\n\r\n        **Single operation**\r\n\r\n        You can also easily adjoint a single operation just by wrapping it with ``adjoint``:\r\n\r\n        .. code-block:: python3\r\n\r\n            dev = qml.device('default.qubit', wires=1)\r\n            @qml.qnode(dev)\r\n            def circuit():\r\n                qml.RX(0.123, wires=0)\r\n                qml.adjoint(qml.RX)(0.123, wires=0)\r\n                return qml.expval(qml.PauliZ(0))\r\n\r\n        This creates the following circuit:\r\n\r\n        >>> print(qml.draw(circuit)())\r\n        0: --RX(0.123)--RX(-0.123)--| <Z>\r\n    \"\"\"\r\n    if not callable(fn):\r\n        raise ValueError(\r\n            f\"The object {fn} of type {type(fn)} is not callable. \"\r\n            \"This error might occur if you apply adjoint to a list \"\r\n            \"of operations instead of a function or template.\"\r\n        )\r\n\r\n    @wraps(fn)\r\n    def wrapper(*args, **kwargs):\r\n        with stop_recording(), QuantumTape() as tape:\r\n            fn(*args, **kwargs)\r\n\r\n        if not tape.operations:\r\n            # we called op.expand(): get the outputted tape\r\n            tape = fn(*args, **kwargs)\r\n\r\n        adjoint_ops = []\r\n        for op in reversed(tape.operations):\r\n            try:\r\n                new_op = op.adjoint()\r\n                adjoint_ops.append(new_op)\r\n            except NotImplementedError:\r\n                # Expand the operation and adjoint the result.\r\n                new_ops = adjoint(op.expand)()\r\n\r\n                if isinstance(new_ops, QuantumTape):\r\n                    new_ops = new_ops.operations\r\n\r\n                adjoint_ops.extend(new_ops)\r\n\r\n        if len(adjoint_ops) == 1:\r\n            adjoint_ops = adjoint_ops[0]\r\n\r\n        return adjoint_ops\r\n\r\n    return wrapper\r\n", "path": "pennylane/transforms/adjoint.py"}]}