class_docstr: Tests that ensure various qubit circuits integrate correctly
class_docstr_tok: ["Tests","that","ensure","various","qubit","circuits","integrate","correctly"]
docstr: Tests correct output shape and evaluation for a tape
  with prob and expval outputs
docstr_tok: ["Tests","correct","output","shape","and","evaluation","for","a","tape","with","prob","and","expval","outputs"]
code: def test_ragged_differentiation(
      self,
      interface,
      dev,
      diff_method,
      grad_on_execution,
      device_vjp,
      tol,
  ):
      """Tests correct output shape and evaluation for a tape
      with prob and expval outputs"""
      if "lightning" in getattr(dev, "short_name", ""):
          pytest.xfail(
              "lightning does not support measureing probabilities with adjoint."
          )
      kwargs = dict(
          diff_method=diff_method,
          grad_on_execution=grad_on_execution,
          interface=interface,
          device_vjp=device_vjp,
      )
      if diff_method == "spsa":
          kwargs["sampler_rng"] = np.random.default_rng(SEED_FOR_SPSA)
          kwargs["num_directions"] = 20
          tol = TOL_FOR_SPSA
  
      x_val = 0.543
      y_val = -0.654
      x = torch.tensor(x_val, requires_grad=True, dtype=torch.float64)
      y = torch.tensor(y_val, requires_grad=True, dtype=torch.float64)
  
      @qnode(dev, **kwargs)
      def circuit(x, y):
          qml.RX(x, wires=[0])
          qml.RY(y, wires=[1])
          qml.CNOT(wires=[0, 1])
          return qml.expval(qml.PauliZ(0)), qml.probs(wires=[1])
  
      res = circuit(x, y)
  
      res_0 = np.array(np.cos(x_val))
      res_1 = np.array(
          [
              (1 + np.cos(x_val) * np.cos(y_val)) / 2,
              (1 - np.cos(x_val) * np.cos(y_val)) / 2,
          ]
      )
  
      assert isinstance(res, tuple)
      assert len(res) == 2
  
      assert np.allclose(
          res[0].detach().numpy(), res_0, atol=tol, rtol=0
      )
      assert np.allclose(
          res[1].detach().numpy(), res_1, atol=tol, rtol=0
      )
  
      jac = jacobian(circuit, (x, y))
  
      res_0 = -np.sin(x_val)
      res_1 = np.array(0.0)
      res_2 = np.array(
          [
              -np.sin(x_val) * np.cos(y_val) / 2,
              np.cos(y_val) * np.sin(x_val) / 2,
          ]
      )
      res_3 = np.array(
          [
              -np.cos(x_val) * np.sin(y_val) / 2,
              +np.cos(x_val) * np.sin(y_val) / 2,
          ]
      )
  
      assert np.allclose(jac[0][0], res_0, atol=tol, rtol=0)
      assert np.allclose(jac[0][1], res_1, atol=tol, rtol=0)
      assert np.allclose(jac[1][0], res_2, atol=tol, rtol=0)
      assert np.allclose(jac[1][1], res_3, atol=tol, rtol=0)
  
imports: import numpy
  import pytest
  import pennylane
  from pennylane import qnode
  from pennylane.devices import DefaultQubit
label_desc: Use image node_id 2 for calling the TestQubitIntegration obj's underlying member method code with example usage: obj.test_ragged_differentiation(interface, dev, diff_method, grad_on_execution, device_vjp, tol) and returns: qml,  qml