class_docstr: Tests for the SPSA gradient transform
class_docstr_tok: ["Tests","for","the","SPSA","gradient","transform"]
docstr: Tests that if sampler_rng has an unexpected type, an error is raised.
docstr_tok: ["Tests","that","if","sampler_rng","has","an","unexpected","type",",","an","error","is","raised","."]
code: def test_invalid_sampler_rng(self):
      """Tests that if sampler_rng has an unexpected type, an error is raised."""
      dev = qml.device("default.qubit", wires=1)
  
      @qml.qnode(dev, diff_method="spsa", sampler_rng="foo")
      def circuit(param):
          qml.RX(param, wires=0)
          return qml.expval(qml.PauliZ(0))
  
      expected_message = (
          "The argument sampler_rng is expected to be a NumPy PRNG"
      )
      with pytest.raises(ValueError, match=expected_message):
          qml.grad(circuit)(np.array(1.0))
  
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 2 for calling the TestSpsaGradient obj's underlying member method code with example usage: obj.test_invalid_sampler_rng() and returns: qml