code: def test_multinomial_0():
      # This tests the MultinomialFromUniform Op directly, not going through the
      # multinomial() call in GPU random generation.
  
      p = tensor.fmatrix()
      u = tensor.fvector()
  
      m = multinomial.MultinomialFromUniform("auto")(p, u)
  
      # the m*2 allows the multinomial to reuse output
      f = function([p, u], m * 2, allow_input_downcast=True)
  
      # test that both first and second samples can be drawn
      utt.assert_allclose(
          f([[1, 0], [0, 1]], [0.1, 0.1]), [[2, 0], [0, 2]]
      )
  
      # test that both second labels can be drawn
      r = f([[0.2, 0.8], [0.3, 0.7]], [0.31, 0.31])
      utt.assert_allclose(r, [[0, 2], [0, 2]])
  
      # test that both first labels can be drawn
      r = f([[0.2, 0.8], [0.3, 0.7]], [0.21, 0.21])
      utt.assert_allclose(r, [[0, 2], [2, 0]])
  
      # change the size to make sure output gets reallocated ok
      # and also make sure that the GPU version doesn't screw up the
      # transposed-ness
      r = f([[0.2, 0.8]], [0.25])
      utt.assert_allclose(r, [[0, 2]])
  
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 4 for calling a global function with example usage: test_multinomial_0() without return types