class_docstr: Tests that ensure various qubit circuits integrate correctly
class_docstr_tok: ["Tests","that","ensure","various","qubit","circuits","integrate","correctly"]
docstr: Test hessian calculation of a ragged QNode
docstr_tok: ["Test","hessian","calculation","of","a","ragged","QNode"]
code: def test_hessian_ragged(
      self,
      interface,
      dev,
      diff_method,
      grad_on_execution,
      device_vjp,
      tol,
  ):
      """Test hessian calculation of a ragged QNode"""
      if diff_method not in {"parameter-shift", "backprop"}:
          pytest.skip("Test only supports parameter-shift or backprop")
  
      @qnode(
          dev,
          diff_method=diff_method,
          interface=interface,
          grad_on_execution=grad_on_execution,
          device_vjp=device_vjp,
          max_diff=2,
      )
      def circuit(x):
          qml.RY(x[0], wires=0)
          qml.RX(x[1], wires=0)
          qml.RY(x[0], wires=1)
          qml.RX(x[1], wires=1)
          return qml.expval(qml.PauliZ(0)), qml.probs(wires=1)
  
      x = np.array([1.0, 2.0], requires_grad=True)
  
      a, b = x
  
      expected_res = [
          np.cos(a) * np.cos(b),
          0.5 + 0.5 * np.cos(a) * np.cos(b),
          0.5 - 0.5 * np.cos(a) * np.cos(b),
      ]
  
      def cost_fn(x):
          return autograd.numpy.hstack(circuit(x))
  
      res = cost_fn(x)
      assert qml.math.allclose(res, expected_res)
  
      jac_fn = qml.jacobian(cost_fn)
  
      hess = qml.jacobian(jac_fn)(x)
      expected_hess = [
          [
              [-np.cos(a) * np.cos(b), np.sin(a) * np.sin(b)],
              [np.sin(a) * np.sin(b), -np.cos(a) * np.cos(b)],
          ],
          [
              [
                  -0.5 * np.cos(a) * np.cos(b),
                  0.5 * np.sin(a) * np.sin(b),
              ],
              [
                  0.5 * np.sin(a) * np.sin(b),
                  -0.5 * np.cos(a) * np.cos(b),
              ],
          ],
          [
              [
                  0.5 * np.cos(a) * np.cos(b),
                  -0.5 * np.sin(a) * np.sin(b),
              ],
              [
                  -0.5 * np.sin(a) * np.sin(b),
                  0.5 * np.cos(a) * np.cos(b),
              ],
          ],
      ]
  
      if diff_method in {"finite-diff"}:
          tol = 10e-2
  
      assert np.allclose(hess, expected_hess, atol=tol, rtol=0)
  
imports: import autograd
  import autograd.numpy
  import pytest
  import pennylane
  from pennylane import numpy
  from pennylane import qnode
  from pennylane.devices import DefaultQubit
label_desc: Use image node_id 13 for calling the TestQubitIntegration obj's underlying member method code with example usage: obj.test_hessian_ragged(interface, dev, diff_method, grad_on_execution, device_vjp, tol) and returns: qml,  qml, autograd