code: def test_consistency_GPUA_parallel():
      # Verify that the random numbers generated by GPUA_mrg_uniform, in
      # parallel, are the same as the reference (Java) implementation by
      # L'Ecuyer et al.
      seed = 12345
      n_samples = 5
      n_streams = 12
      n_substreams = 7  # 7 samples will be drawn in parallel
  
      samples = []
      curr_rstate = np.array([seed] * 6, dtype="int32")
  
      for i in range(n_streams):
          stream_samples = []
          rstate = [curr_rstate.copy()]
          for j in range(1, n_substreams):
              rstate.append(rng_mrg.ff_2p72(rstate[-1]))
          rstate = np.asarray(rstate)
          rstate = gpuarray_shared_constructor(rstate)
  
          new_rstate, sample = GPUA_mrg_uniform.new(
              rstate, ndim=None, dtype="float32", size=(n_substreams,)
          )
          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()
              stream_samples.append(s)
  
          samples.append(np.array(stream_samples).T.flatten())
  
          # 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 2 for calling a global function with example usage: test_consistency_GPUA_parallel() without return types