class_docstr: Tests for the batch_transform decorator differentiability
class_docstr_tok: ["Tests","for","the","batch_transform","decorator","differentiability"]
docstr: Test that a batch transform is differentiable when using
  PyTorch
docstr_tok: ["Test","that","a","batch","transform","is","differentiable","when","using","PyTorch"]
code: def test_differentiable_torch(self, diff_method):
      """Test that a batch 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)
  
      weights_np = np.array([0.1, 0.2], requires_grad=True)
      weights = torch.tensor(
          weights_np, requires_grad=True, dtype=torch.float64
      )
      x_np = np.array(0.543, requires_grad=True)
      x = torch.tensor(x_np, requires_grad=True, dtype=torch.float64)
  
      res = self.my_transform(qnode, weights)(x)
      expected = self.expval(
          x.detach().numpy(), weights.detach().numpy()
      )
      assert np.allclose(res.detach().numpy(), expected)
  
      res.backward()
      expected = qml.grad(self.expval)(x_np, weights_np)
      assert np.allclose(x.grad, expected[0])
      assert np.allclose(weights.grad, expected[1])
  
imports: import functools
  import pytest
  import pennylane
  from pennylane import numpy
label_desc: Use image node_id 6 for calling the TestBatchTransformGradients obj's underlying member method code with example usage: obj.test_differentiable_torch(diff_method) without return types