code: def test_gpu_randomstate(device_id):
      # run 1
      be = gen_backend(backend="gpu", rng_seed=100, device_id=device_id)
      a = be.empty((3, 3))
  
      a[:] = be.rand()  # gpu rand
      x0 = a.get()
      x1 = be.rng.rand(3, 3)  # host rand
      a[:] = be.rand()  # gpu rand
      x2 = a.get()
      be.make_binary_mask(a, keepthresh=be.rng.rand())
      x3 = a.get()
  
      assert (
          len(be.context_rand_state_map) == 1
          and len(be.context_rand_state_alive) == 1
      )
      for ctx in be.context_rand_state_alive:
          assert be.context_rand_state_alive[ctx] is True
  
      # run 2, using reset
      be.rng_reset()
  
      a[:] = be.rand()
      y0 = a.get()
      y1 = be.rng.rand(3, 3)
      a[:] = be.rand()
      y2 = a.get()
      be.make_binary_mask(a, keepthresh=be.rng.rand())
      y3 = a.get()
  
      assert (
          len(be.context_rand_state_map) == 1
          and len(be.context_rand_state_alive) == 1
      )
      for ctx in be.context_rand_state_alive:
          assert be.context_rand_state_alive[ctx] is True
  
      del be
  
      # run 3, using a new backend
      be = gen_backend(backend="gpu", rng_seed=100, device_id=device_id)
      a = be.empty((3, 3))
  
      a[:] = be.rand()  # gpu rand
      z0 = a.get()
      z1 = be.rng.rand(3, 3)  # host rand
      a[:] = be.rand()  # gpu rand
      z2 = a.get()
      be.make_binary_mask(a, keepthresh=be.rng.rand())
      z3 = a.get()
  
      # check equality
      assert tensors_allclose(
          [x0, x1, x2, x3], [y0, y1, y2, y3], rtol=0.0, atol=0.0
      )
      assert tensors_allclose(
          [x0, x1, x2, x3], [z0, z1, z2, z3], rtol=0.0, atol=0.0
      )
  
      del be
  
file_path: neon/tests/test_backend_randomstate.py
imports: import numpy
  import pytest
  from neon.backends import gen_backend
  from utils import tensors_allclose
label_desc: Use image node_id 1 for calling a global function with example usage: test_gpu_randomstate(device_id) without return types