class_docstr: Test the qml.qsvt function.
class_docstr_tok: ["Test","the","qml.qsvt","function","."]
docstr: Test that qml.grad results are the same as finite difference results
docstr_tok: ["Test","that","qml.grad","results","are","the","same","as","finite","difference","results"]
code: def test_qsvt_grad(self):
      """Test that qml.grad results are the same as finite difference results"""
  
      @qml.qnode(qml.device("default.qubit", wires=2))
      def circuit(A, phis):
          qml.qsvt(
              A,
              phis,
              wires=[0, 1],
          )
          return qml.expval(qml.PauliZ(wires=0))
  
      A = np.array(
          [[0.1, 0.2], [0.3, 0.4]], dtype=complex, requires_grad=True
      )
      phis = np.array(
          [0.1, 0.2, 0.3], dtype=complex, requires_grad=True
      )
      y = circuit(A, phis)
  
      mat_grad_results, phi_grad_results = qml.grad(circuit)(A, phis)
  
      diff = 1e-8
  
      manual_mat_results = [
          (circuit(A + np.array([[diff, 0], [0, 0]]), phis) - y) / diff,
          (circuit(A + np.array([[0, diff], [0, 0]]), phis) - y) / diff,
          (circuit(A + np.array([[0, 0], [diff, 0]]), phis) - y) / diff,
          (circuit(A + np.array([[0, 0], [0, diff]]), phis) - y) / diff,
      ]
  
      for idx, result in enumerate(manual_mat_results):
          assert np.isclose(
              result,
              np.real(mat_grad_results.flatten()[idx]),
              atol=1e-6,
          )
  
      manual_phi_results = [
          (circuit(A, phis + np.array([diff, 0, 0])) - y) / diff,
          (circuit(A, phis + np.array([0, diff, 0])) - y) / diff,
          (circuit(A, phis + np.array([0, 0, diff])) - y) / diff,
      ]
  
      for idx, result in enumerate(manual_phi_results):
          assert np.isclose(
              result, np.real(phi_grad_results[idx]), atol=1e-6
          )
  
imports: import pytest
  import pennylane
  from pennylane import numpy
label_desc: Use image node_id 7 for calling the Testqsvt obj's underlying member method code with example usage: obj.test_qsvt_grad() and returns: qml