class_docstr: Tests that the ControlledSequence is executable and differentiable in a QNode context
class_docstr_tok: ["Tests","that","the","ControlledSequence","is","executable","and","differentiable","in","a","QNode","context"]
docstr: Test that the QNode executes and is differentiable with Torch. The shots
  argument controls whether autodiff or parameter-shift gradients are used.
docstr_tok: ["Test","that","the","QNode","executes","and","is","differentiable","with","Torch",".","The","shots","argument","controls","whether","autodiff","or","parameter-shift","gradients","are","used","."]
code: def test_qnode_torch(self, shots):
      """Test that the QNode executes and is differentiable with Torch. The shots
      argument controls whether autodiff or parameter-shift gradients are used.
      """
      import torch
  
      dev = qml.device("default.qubit", shots=shots, seed=10)
      diff_method = "backprop" if shots is None else "parameter-shift"
      qnode = qml.QNode(
          self.circuit, dev, interface="torch", diff_method=diff_method
      )
  
      x = torch.tensor(self.x, requires_grad=True)
      res = qnode(x)
      assert qml.math.shape(res) == (16,)
      assert qml.math.allclose(res, self.exp_result, atol=0.002)
  
      jac = torch.autograd.functional.jacobian(qnode, x)
      assert qml.math.shape(jac) == (16,)
      assert qml.math.allclose(jac, self.exp_jac, atol=0.006)
  
imports: import pytest
  import numpy
  from pennylane import numpy
  import pennylane
  from pennylane.wires import Wires
label_desc: Use image node_id 5 for calling the TestIntegration obj's underlying member method code with example usage: obj.test_qnode_torch(shots) without return types