class_docstr: Integration tests to ensure that the single shot gradient is correctly computed
  for a variety of argument types.
docstr: Test that a simple QNode with multiple scalar arguments correctly performs an optimization step,
  and that the single-shot gradients generated have the correct shape
docstr_tok: ["Test","that","a","simple","QNode","with","multiple","scalar","arguments","correctly","performs","an","optimization","step",",","and","that","the","single-shot","gradients","generated","have","the","correct","shape"]
code: def test_multiple_argument_step(self, mocker, monkeypatch):
      """Test that a simple QNode with multiple scalar arguments correctly performs an optimization step,
      and that the single-shot gradients generated have the correct shape
      """
      # pylint: disable=protected-access
      dev = qml.device("default.qubit", wires=1, shots=100)
  
      @qml.qnode(dev)
      def circuit(x, y):
          qml.RX(x, wires=0)
          qml.RY(y, wires=0)
          return qml.expval(qml.PauliZ(0))
  
      opt = qml.ShotAdaptiveOptimizer(min_shots=10)
      spy_single_shot = mocker.spy(opt, "_single_shot_qnode_gradients")
      spy_grad = mocker.spy(opt, "compute_grad")
  
      args = [
          np.array(0.1, requires_grad=True),
          np.array(0.2, requires_grad=True),
      ]
      new_x = opt.step(circuit, *args)
  
      assert isinstance(new_x, list)
      assert len(new_x) == 2
  
      spy_single_shot.assert_called_once()
      spy_grad.assert_called_once()
  
      # assert single shot gradients are computed correctly
      single_shot_grads = opt._single_shot_qnode_gradients(
          circuit, args, {}
      )
      assert len(single_shot_grads) == 2
      assert single_shot_grads[0].shape == (10,)
  
      # monkeypatch the optimizer to use the same single shot gradients
      # as previously
      monkeypatch.setattr(
          opt,
          "_single_shot_qnode_gradients",
          lambda *args, **kwargs: single_shot_grads,
      )
  
      # reset the shot budget
      opt.s = [np.array(10), np.array(10)]
  
      # check that the gradient and variance are computed correctly
      grad, grad_variance = opt.compute_grad(circuit, args, {})
      assert len(grad) == 2
      assert len(grad_variance) == 2
      assert np.allclose(grad, np.mean(single_shot_grads, axis=1))
      assert np.allclose(
          grad_variance, np.var(single_shot_grads, ddof=1, axis=1)
      )
  
      # check that the gradient and variance are computed correctly
      # with a different shot budget
      opt.s = [np.array(5), np.array(7)]
      grad, grad_variance = opt.compute_grad(circuit, args, {})
      assert len(grad) == 2
      assert len(grad_variance) == 2
  
      for p, s in zip(range(2), opt.s):
          assert np.allclose(grad[p], np.mean(single_shot_grads[p][:s]))
          assert np.allclose(
              grad_variance[p], np.var(single_shot_grads[p][:s], ddof=1)
          )
  
imports: import pytest
  from flaky import flaky
  import pennylane
  from pennylane import numpy
label_desc: Use image node_id 5 for calling the TestSingleShotGradientIntegration obj's underlying member method code with example usage: obj.test_multiple_argument_step(mocker, monkeypatch) and returns: qml