code: def test_shuffle_row_elements(self):
      # Test that RandomStreams.shuffle_row_elements generates the right results
      # Check over two calls to see if the random state is correctly updated.
  
      # On matrices, for each row, the elements of that row should be shuffled.
      # Note that this differs from np.random.shuffle, where all the elements
      # of the matrix are shuffled.
      random = RandomStreams(utt.fetch_seed())
      m_input = tensor.dmatrix()
      f = function(
          [m_input],
          random.shuffle_row_elements(m_input),
          updates=random.updates(),
      )
  
      # Generate the elements to be shuffled
      val_rng = np.random.RandomState(utt.fetch_seed() + 42)
      in_mval = val_rng.uniform(-2, 2, size=(20, 5))
      fn_mval0 = f(in_mval)
      fn_mval1 = f(in_mval)
      print(in_mval[0])
      print(fn_mval0[0])
      print(fn_mval1[0])
      assert not np.all(in_mval == fn_mval0)
      assert not np.all(in_mval == fn_mval1)
      assert not np.all(fn_mval0 == fn_mval1)
  
      rng_seed = np.random.RandomState(utt.fetch_seed()).randint(
          2**30
      )
      rng = np.random.RandomState(int(rng_seed))
      numpy_mval0 = in_mval.copy()
      numpy_mval1 = in_mval.copy()
      for row in numpy_mval0:
          rng.shuffle(row)
      for row in numpy_mval1:
          rng.shuffle(row)
  
      assert np.all(numpy_mval0 == fn_mval0)
      assert np.all(numpy_mval1 == fn_mval1)
  
      # On vectors, the behaviour is the same as np.random.shuffle,
      # except that it does not work in place, but returns a shuffled vector.
      random1 = RandomStreams(utt.fetch_seed())
      v_input = tensor.dvector()
      f1 = function([v_input], random1.shuffle_row_elements(v_input))
  
      in_vval = val_rng.uniform(-3, 3, size=(12,))
      fn_vval = f1(in_vval)
      numpy_vval = in_vval.copy()
      vrng = np.random.RandomState(int(rng_seed))
      vrng.shuffle(numpy_vval)
      print(in_vval)
      print(fn_vval)
      print(numpy_vval)
      assert np.all(numpy_vval == fn_vval)
  
      # Trying to shuffle a vector with function that should shuffle
      # matrices, or vice versa, raises a TypeError
      self.assertRaises(TypeError, f1, in_mval)
      self.assertRaises(TypeError, f, in_vval)
  
imports: from __future__ import absolute_import, print_function, division
  import sys
  import unittest
  import numpy
  from theano.tensor import raw_random
  from theano.tensor.shared_randomstreams import RandomStreams
  from theano import function, shared
  from theano import tensor
  from theano import compile, config, gof
  from theano.tests import unittest_tools
label_desc: Use image node_id 15 for calling the T_SharedRandomStreams obj's underlying member method code with example usage: obj.test_shuffle_row_elements() without return types