class_docstr: Tests for weighted random Hamiltonian term sampling
docstr: Test that, if the shot budget for a single term is 0,
  that the jacobian computation is skipped
docstr_tok: ["Test","that",",","if","the","shot","budget","for","a","single","term","is","0",",","that","the","jacobian","computation","is","skipped"]
code: def test_zero_shots(self, mocker):
      """Test that, if the shot budget for a single term is 0,
      that the jacobian computation is skipped"""
      coeffs = [0.2, 0.1, 0.1]
      dev = qml.device("default.qubit", wires=2, shots=100)
      H = qml.Hamiltonian(
          coeffs,
          [qml.PauliZ(0), qml.PauliX(1), qml.PauliZ(0) @ qml.PauliZ(1)],
      )
  
      @qml.qnode(dev)
      def circuit(weights):
          qml.StronglyEntanglingLayers(weights, wires=range(2))
          return qml.expval(H)
  
      weights = np.random.random(
          qml.templates.StronglyEntanglingLayers.shape(3, 2)
      )
  
      opt = qml.ShotAdaptiveOptimizer(min_shots=10)
      spy = mocker.spy(qml, "jacobian")
      mocker.patch(
          "scipy.stats._multivariate.multinomial_gen.rvs",
          return_value=np.array([[4, 0, 6]]),
      )
      grads = opt.qnode_weighted_random_sampling(
          circuit, coeffs, H.ops, 10, [0], weights
      )
  
      assert len(spy.call_args_list) == 2
      assert len(grads) == 1
      assert grads[0].shape == (10, *weights.shape)
  
imports: import pytest
  from flaky import flaky
  import pennylane
  from pennylane import numpy
label_desc: Use image node_id 5 for calling the TestQNodeWeightedRandomSampling obj's underlying member method code with example usage: obj.test_zero_shots(mocker) and returns: qml