code: def test_consistency_GPUA_serial():
      # Verify that the random numbers generated by GPUA_mrg_uniform, serially,
      # are the same as the reference (Java) implementation by L'Ecuyer et al.
  
      seed = 12345
      n_samples = 5
      n_streams = 12
      n_substreams = 7
  
      samples = []
      curr_rstate = np.array([seed] * 6, dtype="int32")
  
      for i in range(n_streams):
          stream_rstate = curr_rstate.copy()
          for j in range(n_substreams):
              substream_rstate = np.array(
                  [stream_rstate.copy()], dtype="int32"
              )
              # Transfer to device
              rstate = gpuarray_shared_constructor(substream_rstate)
  
              new_rstate, sample = GPUA_mrg_uniform.new(
                  rstate, ndim=None, dtype="float32", size=(1,)
              )
              rstate.default_update = new_rstate
  
              # Not really necessary, just mimicking
              # rng_mrg.MRG_RandomStreams' behavior
              sample.rstate = rstate
              sample.update = (rstate, new_rstate)
  
              # We need the sample back in the main memory
              cpu_sample = tensor.as_tensor_variable(sample)
              f = theano.function([], cpu_sample, mode=mode)
              for k in range(n_samples):
                  s = f()
                  samples.append(s)
  
              # next substream
              stream_rstate = rng_mrg.ff_2p72(stream_rstate)
  
          # next stream
          curr_rstate = rng_mrg.ff_2p134(curr_rstate)
  
      samples = np.array(samples).flatten()
      assert np.allclose(samples, java_samples)
  
file_path: Theano/theano/gpuarray/tests/test_rng_mrg.py
imports: from __future__ import absolute_import, print_function, division
  import functools
  import numpy
  import theano
  from theano import change_flags, tensor
  from theano.sandbox import rng_mrg
  from theano.sandbox.rng_mrg import MRG_RandomStreams
  from theano.sandbox.tests.test_rng_mrg import java_samples, rng_mrg_overflow
  from theano.sandbox.tests.test_rng_mrg import test_f16_nonzero
  from theano.tests import unittest_tools
  from .config import mode_with_gpu
  from ..type import gpuarray_shared_constructor
  from ..rng_mrg import GPUA_mrg_uniform
label_desc: Use image node_id 1 for calling a global function with example usage: test_consistency_GPUA_serial() without return types