code: def test_random_function_ndim(self):
      # Test that random_function helper function accepts argument ndim
      rng_R = random_state_type()
  
      # ndim is an optional argument indicating the length of the 'shape'
      # ndim not specified, OK
      post_out4, out4 = uniform(rng_R, (4,))
  
      # ndim specified, consistent with shape, OK
      post_out1_4, out1_4 = uniform(rng_R, (4,), ndim=1)
      post_out2_4_4, out2_4_4 = uniform(rng_R, (4, 4), ndim=2)
  
      # ndim specified, but not compatible with shape
      self.assertRaises(ValueError, uniform, rng_R, (4,), ndim=2)
  
      f_ok = compile.function(
          [
              compile.In(
                  rng_R,
                  value=np.random.RandomState(utt.fetch_seed()),
                  update=post_out2_4_4,
                  mutable=True,
              )
          ],
          [out4, out1_4, out2_4_4],
          accept_inplace=True,
      )
  
      # The correct cases should execute properly
      o4, o1_4, o2_4_4 = f_ok()
  
      # Check the sanity of the answers
      self.assertTrue(np.allclose(o4, o1_4))
      self.assertTrue(np.allclose(o4, o2_4_4[0]))
  
imports: from __future__ import absolute_import, print_function, division
  import numpy
  import pickle
  from theano.tests import unittest_tools
  from theano.tensor.raw_random import *
  from theano.tensor import raw_random, ivector, dvector, iscalar, dcol, dtensor3
  from theano import tensor
  from theano import compile, config, gof
label_desc: Use image node_id 7 for calling the T_random_function obj's underlying member method code with example usage: obj.test_random_function_ndim() without return types