class_docstr: Tests for integration with the PassthruQNode
class_docstr_tok: ["Tests","for","integration","with","the","PassthruQNode"]
docstr: Tests that the gradient of expval is correct
docstr_tok: ["Tests","that","the","gradient","of","expval","is","correct"]
code: def test_expval_gradient(self, tol):
      """Tests that the gradient of expval is correct"""
      dev = qml.device("default.mixed", wires=2)
  
      @qml.qnode(dev, diff_method="backprop", interface="torch")
      def circuit(a, b):
          qml.RX(a, wires=0)
          qml.CRX(b, wires=[0, 1])
          return qml.expval(qml.PauliZ(0) @ qml.PauliZ(1))
  
      a = torch.tensor(-0.234, dtype=torch.float64, requires_grad=True)
      b = torch.tensor(0.654, dtype=torch.float64, requires_grad=True)
  
      res = circuit(a, b)
      res.backward()
  
      expected_cost = 0.5 * (
          torch.cos(a) * torch.cos(b) + torch.cos(a) - torch.cos(b) + 1
      )
      assert torch.allclose(res, expected_cost, atol=tol, rtol=0)
  
      assert torch.allclose(
          a.grad,
          -0.5 * torch.sin(a) * (torch.cos(b) + 1),
          atol=tol,
          rtol=0,
      )
      assert torch.allclose(
          b.grad,
          0.5 * torch.sin(b) * (1 - torch.cos(a)),
          atol=tol,
          rtol=0,
      )
  
imports: import pytest
  import numpy
  import pennylane
  from pennylane import numpy
  from pennylane.devices.default_mixed import DefaultMixed
label_desc: Use image node_id 10 for calling the TestPassthruIntegration obj's underlying member method code with example usage: obj.test_expval_gradient(tol) and returns: qml