code: def test_gpu_opt_wor():
      # We test the case where we put the op on the gpu when the output
      # is moved to the gpu.
      p = tensor.fmatrix()
      u = tensor.fvector()
      n = tensor.iscalar()
      for replace in [False, True]:
          m = multinomial.ChoiceFromUniform(
              odtype="auto", replace=replace
          )(p, u, n)
          assert m.dtype == "int64", m.dtype
  
          f = function(
              [p, u, n],
              m,
              allow_input_downcast=True,
              mode=mode_with_gpu,
          )
          assert any(
              [
                  type(node.op) is GPUAChoiceFromUniform
                  for node in f.maker.fgraph.toposort()
              ]
          )
          n_samples = 3
          pval = (
              np.arange(10000 * 4, dtype="float32").reshape((10000, 4))
              + 0.1
          )
          pval = pval / pval.sum(axis=1)[:, None]
          uval = np.ones(pval.shape[0] * n_samples) * 0.5
          f(pval, uval, n_samples)
  
          # Test with a row, it was failing in the past.
          r = tensor.frow()
          m = multinomial.ChoiceFromUniform("auto", replace=replace)(
              r, u, n
          )
          assert m.dtype == "int64", m.dtype
  
          f = function(
              [r, u, n],
              m,
              allow_input_downcast=True,
              mode=mode_with_gpu,
          )
          assert any(
              [
                  type(node.op) is GPUAChoiceFromUniform
                  for node in f.maker.fgraph.toposort()
              ]
          )
          pval = np.arange(1 * 4, dtype="float32").reshape((1, 4)) + 0.1
          pval = pval / pval.sum(axis=1)[:, None]
          uval = np.ones_like(pval[:, 0]) * 0.5
          f(pval, uval, 1)
  
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 6 for calling a global function with example usage: test_gpu_opt_wor() without return types