class_docstr: Tests for the SPSA gradient transform
class_docstr_tok: ["Tests","for","the","SPSA","gradient","transform"]
docstr: Test that the Jacobian is correctly returned for a tape with ragged output
docstr_tok: ["Test","that","the","Jacobian","is","correctly","returned","for","a","tape","with","ragged","output"]
code: def test_ragged_output(self, approx_order, strategy, validate):
      """Test that the Jacobian is correctly returned for a tape with ragged output"""
      dev = qml.device(
          "default.qubit", wires=3, shots=many_shots_shot_vector
      )
      params = [1.0, 1.0, 1.0]
      rng = np.random.default_rng(42)
  
      with qml.queuing.AnnotatedQueue() as q:
          qml.RX(params[0], wires=[0])
          qml.RY(params[1], wires=[1])
          qml.RZ(params[2], wires=[2])
          qml.CNOT(wires=[0, 1])
          qml.probs(wires=0)
          qml.probs(wires=[1, 2])
  
      tape = qml.tape.QuantumScript.from_queue(
          q, shots=many_shots_shot_vector
      )
      tapes, fn = spsa_grad(
          tape,
          approx_order=approx_order,
          strategy=strategy,
          validate_params=validate,
          num_directions=3,
          sampler_rng=rng,
      )
      all_res = fn(dev.execute(tapes))
      assert isinstance(all_res, tuple)
      assert len(all_res) == len(many_shots_shot_vector)
  
      for res in all_res:
          assert isinstance(res, tuple)
  
          assert len(res) == 2
  
          assert len(res[0]) == 3
          assert res[0][0].shape == (2,)
          assert res[0][1].shape == (2,)
          assert res[0][2].shape == (2,)
  
          assert len(res[1]) == 3
          assert res[1][0].shape == (4,)
          assert res[1][1].shape == (4,)
          assert res[1][2].shape == (4,)
  
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 1 for calling the TestSpsaGradientIntegration obj's underlying member method code with example usage: obj.test_ragged_output(approx_order, strategy, validate) without return types