class_docstr: Test the adjoint method for the metric tensor when calling it on
  a QNode.
class_docstr_tok: ["Test","the","adjoint","method","for","the","metric","tensor","when","calling","it","on","a","QNode","."]
docstr: Test that the output is correct when using Torch and
  calling the adjoint metric tensor on a QNode.
docstr_tok: ["Test","that","the","output","is","correct","when","using","Torch","and","calling","the","adjoint","metric","tensor","on","a","QNode","."]
code: def test_correct_output_qnode_torch(
      self, ansatz, params, interface, dev_name
  ):
      """Test that the output is correct when using Torch and
      calling the adjoint metric tensor on a QNode."""
  
      import torch
  
      expected = autodiff_metric_tensor(ansatz, self.num_wires)(*params)
      t_params = tuple(
          torch.tensor(p, requires_grad=True, dtype=torch.float64)
          for p in params
      )
      dev = qml.device(dev_name, wires=self.num_wires)
  
      @qml.qnode(dev, interface=interface)
      def circuit(*params):
          """Circuit with dummy output to create a QNode."""
          ansatz(*params, dev.wires)
          return qml.expval(qml.PauliZ(0))
  
      mt = qml.adjoint_metric_tensor(circuit)(*t_params)
  
      if isinstance(mt, tuple):
          assert all(
              qml.math.allclose(_mt, _exp)
              for _mt, _exp in zip(mt, expected)
          )
      else:
          assert qml.math.allclose(mt, expected)
  
imports: import pytest
  from pennylane import numpy
  import pennylane
label_desc: Use image node_id 3 for calling the TestAdjointMetricTensorQNode obj's underlying member method code with example usage: obj.test_correct_output_qnode_torch(ansatz, params, interface, dev_name) and returns: qml