class_docstr: Tests for the SPSA gradient transform
class_docstr_tok: ["Tests","for","the","SPSA","gradient","transform"]
docstr: Test that if first order finite differences is underlying the SPSA, then
  the tape is executed only once using the current parameter
  values.
docstr_tok: ["Test","that","if","first","order","finite","differences","is","underlying","the","SPSA",",","then","the","tape","is","executed","only","once","using","the","current","parameter","values","."]
code: def test_y0(self):
      """Test that if first order finite differences is underlying the SPSA, then
      the tape is executed only once using the current parameter
      values."""
      with qml.queuing.AnnotatedQueue() as q:
          qml.RX(0.543, wires=[0])
          qml.RY(-0.654, wires=[0])
          qml.expval(qml.PauliZ(0))
  
      tape = qml.tape.QuantumScript.from_queue(
          q, shots=default_shot_vector
      )
      n = 5
      tapes, _ = spsa_grad(
          tape,
          strategy="forward",
          approx_order=1,
          h=h_val,
          num_directions=n,
      )
  
      # one tape per direction, plus one global call
      assert len(tapes) == n + 1
  
imports: import numpy
  import pytest
  from pennylane import numpy
  import pennylane
  from pennylane.gradients import spsa_grad
  from pennylane.devices import DefaultQubitLegacy
  from pennylane.measurements import Shots
  from pennylane.operation import Observable, AnyWires
label_desc: Use image node_id 11 for calling the TestSpsaGradient obj's underlying member method code with example usage: obj.test_y0() without return types