code: def test_n_samples_2():
      p = tensor.fmatrix()
      u = tensor.fvector()
      n = tensor.iscalar()
      m = multinomial.MultinomialFromUniform("auto")(p, u, n)
  
      f = function([p, u, n], m, allow_input_downcast=True)
  
      np.random.seed(12345)
      for i in [1, 5, 10, 100, 1000]:
          uni = np.random.rand(i).astype(config.floatX)
          pvals = np.random.randint(1, 1000, (1, 1000)).astype(
              config.floatX
          )
          pvals /= pvals.sum(1)
          res = f(pvals, uni, i)
          assert res.sum() == i
  
      for i in [1, 5, 10, 100, 1000]:
          uni = np.random.rand(i).astype(config.floatX)
          pvals = np.random.randint(1, 1000000, (1, 1000000)).astype(
              config.floatX
          )
          pvals /= pvals.sum(1)
          res = f(pvals, uni, i)
          assert res.sum() == i
  
file_path: Theano/theano/sandbox/tests/test_multinomial.py
imports: from __future__ import absolute_import, print_function, division
  import os
  import sys
  from six import reraise
  from nose.plugins.skip import SkipTest
  import numpy
  import theano
  from theano import config, function, tensor
  from theano.sandbox import multinomial
  import theano.tests.unittest_tools
  from theano.compat import PY3
  from theano.misc.pkl_utils import CompatUnpickler
label_desc: Use image node_id 2 for calling a global function with example usage: test_n_samples_2() without return types