class_docstr: Test the torch interface execute function
  integrates well for both forward and backward execution
class_docstr_tok: ["Test","the","torch","interface","execute","function","integrates","well","for","both","forward","and","backward","execution"]
docstr: Test jacobian calculation
docstr_tok: ["Test","jacobian","calculation"]
code: def test_jacobian(self, execute_kwargs, shots, device):
      """Test jacobian calculation"""
      a = torch.tensor(0.1, requires_grad=True)
      b = torch.tensor(0.2, requires_grad=True)
  
      def cost(a, b):
          ops = [
              qml.RY(a, wires=0),
              qml.RX(b, wires=1),
              qml.CNOT(wires=[0, 1]),
          ]
          m = [qml.expval(qml.PauliZ(0)), qml.expval(qml.PauliY(1))]
          tape = qml.tape.QuantumScript(ops, m, shots=shots)
          [res] = execute([tape], device, **execute_kwargs)
          if shots.has_partitioned_shots:
              return torch.hstack(res[0] + res[1])
          return torch.hstack(res)
  
      res = cost(a, b)
      expected = torch.tensor(
          [torch.cos(a), -torch.cos(a) * torch.sin(b)]
      )
      if shots.has_partitioned_shots:
          assert torch.allclose(
              res[:2], expected, atol=atol_for_shots(shots), rtol=0
          )
          assert torch.allclose(
              res[2:], expected, atol=atol_for_shots(shots), rtol=0
          )
      else:
          assert torch.allclose(
              res, expected, atol=atol_for_shots(shots), rtol=0
          )
  
      res = torch.autograd.functional.jacobian(cost, (a, b))
      assert isinstance(res, tuple) and len(res) == 2
  
      expected = (
          torch.tensor([-torch.sin(a), torch.sin(a) * torch.sin(b)]),
          torch.tensor([0, -torch.cos(a) * torch.cos(b)]),
      )
      if shots.has_partitioned_shots:
          assert res[0].shape == (4,)
          assert res[1].shape == (4,)
  
          for _r, _e in zip(res, expected):
              assert torch.allclose(
                  _r[:2], _e, atol=atol_for_shots(shots)
              )
              assert torch.allclose(
                  _r[2:], _e, atol=atol_for_shots(shots)
              )
  
      else:
          assert res[0].shape == (2,)
          assert res[1].shape == (2,)
  
          for _r, _e in zip(res, expected):
              assert torch.allclose(_r, _e, atol=atol_for_shots(shots))
  
imports: import numpy
  import pytest
  from param_shift_dev import ParamShiftDerivativesDevice
  import pennylane
  from pennylane.devices import DefaultQubit
  from pennylane.gradients import param_shift
  from pennylane import execute
  from pennylane.measurements import Shots
label_desc: Use image node_id 3 for calling the TestTorchExecuteIntegration obj's underlying member method code with example usage: obj.test_jacobian(execute_kwargs, shots, device) and returns: torch, torch