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)
      n = 13
      tapes, _ = spsa_grad(
          tape, strategy="forward", approx_order=1, num_directions=n
      )
  
      # one tape per direction, plus one global call
      assert len(tapes) == n + 1
  
imports: import numpy
  import pytest
  import pennylane
  from pennylane import numpy
  from pennylane.devices import DefaultQubitLegacy
  from pennylane.gradients import spsa_grad
  from pennylane.gradients.spsa_gradient import _rademacher_sampler
  from pennylane.operation import AnyWires, Observable
label_desc: Use image node_id 14 for calling the TestSpsaGradient obj's underlying member method code with example usage: obj.test_y0() without return types