class_docstr: Tests for the SPSA gradient transform
class_docstr_tok: ["Tests","for","the","SPSA","gradient","transform"]
docstr: Test that by providing y0 the number of tapes is equal the number of parameters.
docstr_tok: ["Test","that","by","providing","y0","the","number","of","tapes","is","equal","the","number","of","parameters","."]
code: def test_y0_provided(self):
      """Test that by providing y0 the number of tapes is equal the number of parameters."""
      dev = qml.device("default.qubit", wires=2)
  
      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)
      f0 = dev.execute(tape)
      n = 9
      tapes, _ = spsa_grad(
          tape,
          strategy="forward",
          approx_order=1,
          num_directions=n,
          f0=f0,
      )
      # one tape per direction, the unshifted one already was evaluated above
      assert len(tapes) == n
  
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 15 for calling the TestSpsaGradient obj's underlying member method code with example usage: obj.test_y0_provided() without return types