class_docstr: Tests for the ``adjoint_jacobian`` method
class_docstr_tok: ["Tests","for","the","``","adjoint_jacobian","``","method"]
docstr: Test that the gradients of multiple observables are correct
docstr_tok: ["Test","that","the","gradients","of","multiple","observables","are","correct"]
code: def test_multi_return(self, dev):
      """Test that the gradients of multiple observables are correct"""
  
      x = np.array([0.6, 0.8, 1.0])
  
      ops = [
          qml.Hadamard(wires=0),
          qml.RX(0.543, wires=0),
          qml.CNOT(wires=[0, 1]),
          qml.Rot(x[0], x[1], x[2], wires=0),
          qml.Rot(1.3, -2.3, 0.5, wires=[0]),
          qml.RZ(-0.5, wires=0),
          qml.RY(0.5, wires=1),
          qml.CNOT(wires=[0, 1]),
      ]
  
      observables = [
          qml.PauliX(0),
          qml.PauliX(0) @ qml.PauliZ(1),
          qml.Projector([0], wires=0),
          qml.Hermitian([[0, 1], [1, 0]], wires=1),
      ]
  
      with qml.queuing.AnnotatedQueue() as q:
          for op in ops:
              qml.apply(op)
  
          for ob in observables:
              qml.expval(ob)
  
      tape = qml.tape.QuantumScript.from_queue(q)
      tape.trainable_params = {1, 2, 3}
  
      grad_D = dev.adjoint_jacobian(tape)
  
      # check that the type and format of the adjoint jacobian is correct
      assert isinstance(grad_D, tuple)
      assert len(grad_D) == len(observables)
      assert all(isinstance(g, tuple) for g in grad_D)
      assert all(len(g) == 3 for g in grad_D)
      assert all(
          all(isinstance(_g, np.ndarray) for _g in g) for g in grad_D
      )
  
      # check the results against individually executed tapes
      for i, ob in enumerate(observables):
          with qml.queuing.AnnotatedQueue() as q_indiv_tape:
              for op in ops:
                  qml.apply(op)
  
              qml.expval(ob)
  
          indiv_tape = qml.tape.QuantumScript.from_queue(q_indiv_tape)
          indiv_tape.trainable_params = {1, 2, 3}
  
          expected = dev.adjoint_jacobian(indiv_tape)
  
          assert isinstance(expected, tuple)
          assert len(expected) == 3
          assert all(isinstance(g, np.ndarray) for g in expected)
  
          assert np.allclose(grad_D[i], expected)
  
imports: import pytest
  import pennylane
  from pennylane import numpy
label_desc: Use image node_id 17 for calling the TestAdjointJacobian obj's underlying member method code with example usage: obj.test_multi_return(dev) without return types