class_docstr: Test the Rademacher distribution sampler.
class_docstr_tok: ["Test","the","Rademacher","distribution","sampler","."]
docstr: Test that the output is the same for identical RNGs.
docstr_tok: ["Test","that","the","output","is","the","same","for","identical","RNGs","."]
code: def test_same_seeds(self):
      """Test that the output is the same for identical RNGs."""
      ids = [0, 1, 2, 3, 4]
      num = 5
      rng = np.random.default_rng(42)
      first_direction = _rademacher_sampler(ids, num, rng=rng)
      np.random.seed(
          0
      )  # Setting the global seed should have no effect.
      rng = np.random.default_rng(42)
      second_direction = _rademacher_sampler(ids, num, rng=rng)
      assert np.allclose(first_direction, second_direction)
  
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 4 for calling the TestRademacherSampler obj's underlying member method code with example usage: obj.test_same_seeds() without return types