class_docstr: Tests for the qfunc_transform decorator differentiability
class_docstr_tok: ["Tests","for","the","qfunc_transform","decorator","differentiability"]
docstr: Test that a qfunc transform is differentiable when using
  PyTorch
docstr_tok: ["Test","that","a","qfunc","transform","is","differentiable","when","using","PyTorch"]
code: def test_differentiable_qfunc_torch(self, diff_method):
      """Test that a qfunc transform is differentiable when using
      PyTorch"""
      import torch
  
      dev = qml.device("default.qubit", wires=2)
      qnode = qml.QNode(self.circuit, dev, diff_method=diff_method)
  
      a_np = np.array(0.5, requires_grad=True)
      b_np = np.array([0.1, 0.2], requires_grad=True)
      x_np = np.array(0.543, requires_grad=True)
      a = torch.tensor(a_np, requires_grad=True)
      b = torch.tensor(b_np, requires_grad=True)
      x = torch.tensor(x_np, requires_grad=True)
  
      res = qnode(x, a, b)
      expected = self.expval(x_np, a_np, b_np)
      assert np.allclose(res.detach().numpy(), expected)
  
      res.backward()
      expected = qml.grad(self.expval)(x_np, a_np, b_np)
      assert np.allclose(x.grad, expected[0])
      assert np.allclose(a.grad, expected[1])
      assert np.allclose(b.grad, expected[2])
  
imports: import pytest
  import pennylane
  from pennylane import numpy
label_desc: Use image node_id 7 for calling the TestQFuncTransformGradients obj's underlying member method code with example usage: obj.test_differentiable_qfunc_torch(diff_method) without return types