code: def test_multinomial_output_dtype():
      # This tests the MultinomialFromUniform Op directly, not going through the
      # multinomial() call in GPU random generation.
  
      p = tensor.fmatrix()
      u = tensor.fvector()
  
      for dtype in [
          "int64",
          "float32",
          "float16",
          "float64",
          "int32",
          "auto",
      ]:
          m = theano.sandbox.multinomial.MultinomialFromUniform(dtype)(
              p, u
          )
  
          # the m*2 allows the multinomial to reuse output
          f = function(
              [p, u],
              m * 2,
              allow_input_downcast=True,
              mode=mode_with_gpu,
          )
  
          assert any(
              [
                  type(node.op) is GPUAMultinomialFromUniform
                  for node in f.maker.fgraph.toposort()
              ]
          )
  
          # 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]])
  
imports: from __future__ import absolute_import, print_function, division
  import os
  import numpy
  import unittest
  import theano
  from theano import config, function, tensor
  from theano.compat import PY3
  from theano.misc.pkl_utils import CompatUnpickler
  from theano.sandbox import multinomial
  from theano.sandbox.rng_mrg import MRG_RandomStreams
  import theano.tests.unittest_tools
  from .config import mode_with_gpu
  from ..multinomial import GPUAMultinomialFromUniform, GPUAChoiceFromUniform
label_desc: Use image node_id 1 for calling a global function with example usage: test_multinomial_output_dtype() without return types