class_docstr: Tests for the SPSA gradient transform
class_docstr_tok: ["Tests","for","the","SPSA","gradient","transform"]
docstr: Test that an independent parameter is skipped
  during the Jacobian computation.
docstr_tok: ["Test","that","an","independent","parameter","is","skipped","during","the","Jacobian","computation","."]
code: def test_independent_parameter(self, num_directions, mocker):
      """Test that an independent parameter is skipped
      during the Jacobian computation."""
      spy = mocker.spy(
          qml.gradients.spsa_gradient, "generate_multishifted_tapes"
      )
  
      with qml.queuing.AnnotatedQueue() as q:
          qml.RX(0.543, wires=[0])
          qml.RY(-0.654, wires=[1])
          qml.expval(qml.PauliZ(0))
  
      tape = qml.tape.QuantumScript.from_queue(
          q, shots=default_shot_vector
      )
      dev = qml.device(
          "default.qubit", wires=2, shots=default_shot_vector
      )
      tapes, fn = spsa_grad(
          tape, h=h_val, num_directions=num_directions
      )
      all_res = fn(dev.execute(tapes))
  
      assert isinstance(all_res, tuple)
      assert len(all_res) == len(default_shot_vector)
  
      for res in all_res:
          assert isinstance(res, tuple)
          assert len(res) == 2
  
          assert isinstance(res[0], numpy.ndarray)
          assert isinstance(res[1], numpy.ndarray)
  
      # 2 tapes per direction because the default strategy for SPSA is "center"
      assert len(spy.call_args_list) == num_directions
  
      # Never shift the independent parameter
      for i in range(num_directions):
          assert spy.call_args_list[i][0][0:2] == (tape, [0])
          assert spy.call_args_list[i][0][2].shape == (2, 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 2 for calling the TestSpsaGradient obj's underlying member method code with example usage: obj.test_independent_parameter(num_directions, mocker) without return types