class_docstr: Tests that ensure various qubit circuits integrate correctly
class_docstr_tok: ["Tests","that","ensure","various","qubit","circuits","integrate","correctly"]
docstr: Test that the gradient of chained QNodes works without error
docstr_tok: ["Test","that","the","gradient","of","chained","QNodes","works","without","error"]
code: def test_chained_qnodes(
      self, dev, diff_method, grad_on_execution, device_vjp
  ):
      """Test that the gradient of chained QNodes works without error"""
      # pylint:disable=too-few-public-methods
  
      class Template(qml.templates.StronglyEntanglingLayers):
          def decomposition(self):
              return [
                  qml.templates.StronglyEntanglingLayers(
                      *self.parameters, self.wires
                  )
              ]
  
      @qnode(
          dev,
          interface="jax",
          diff_method=diff_method,
          grad_on_execution=grad_on_execution,
          device_vjp=device_vjp,
      )
      def circuit1(weights):
          Template(weights, wires=[0, 1])
          return qml.expval(qml.PauliZ(0))
  
      @qnode(
          dev,
          interface="jax",
          diff_method=diff_method,
          grad_on_execution=grad_on_execution,
          device_vjp=device_vjp,
      )
      def circuit2(data, weights):
          qml.templates.AngleEmbedding(
              jax.numpy.stack([data, 0.7]), wires=[0, 1]
          )
          Template(weights, wires=[0, 1])
          return qml.expval(qml.PauliX(0))
  
      def cost(weights):
          w1, w2 = weights
          c1 = circuit1(w1)
          c2 = circuit2(c1, w2)
          return jax.numpy.sum(c2) ** 2
  
      w1 = qml.templates.StronglyEntanglingLayers.shape(
          n_wires=2, n_layers=3
      )
      w2 = qml.templates.StronglyEntanglingLayers.shape(
          n_wires=2, n_layers=4
      )
  
      weights = [
          jax.numpy.array(np.random.random(w1)),
          jax.numpy.array(np.random.random(w2)),
      ]
  
      grad_fn = jax.grad(cost)
      res = grad_fn(weights)
  
      assert len(res) == 2
  
imports: from itertools import product
  import numpy
  import pytest
  import pennylane
  from pennylane import qnode
  from pennylane.devices import DefaultQubit
label_desc: Use image node_id 3 for calling the TestQubitIntegration obj's underlying member method code with example usage: obj.test_chained_qnodes(dev, diff_method, grad_on_execution, device_vjp) and returns: qml, qml, unknown, list