code: def test_many_arg_elemwise():
      # This test checks whether the + and * elemwise ops can handle
      # extremely large numbers of arguments on gpu.
  
      rng = np.random.RandomState([1, 2, 3])
      nb_of_inputs_overflows = []
      for num_args in [64]:
          for op_to_test in [theano.tensor.add, theano.tensor.mul]:
              for nb_dim in [2, 8]:
                  shapes = [rng.randint(1, 5) for i in range(nb_dim)]
                  args = [
                      np.cast["float32"](rng.randn(*shapes))
                      for arg in range(0, num_args)
                  ]
  
                  symb_args = [
                      theano.tensor.TensorType(
                          "float32", (False,) * nb_dim
                      )()
                      for arg in range(0, num_args)
                  ]
  
                  outputs = []
                  for mode in [mode_with_gpu, mode_without_gpu]:
                      # test the optimization local_gpua_elemwise
                      output = op_to_test(*symb_args)
                      f = theano.function(symb_args, output, mode=mode)
                      outputs.append(f(*args))
  
                      # assert that the test was done on the gpu.
                      if mode is mode_with_gpu:
                          nb_of_inputs_overflows.append(
                              max_inputs_to_GpuElemwise(output.owner)
                              - num_args
                          )
                          nodelst = [
                              node
                              for node in f.maker.fgraph.apply_nodes
                          ]
                          assert any(
                              isinstance(node.op, GpuElemwise)
                              for node in nodelst
                          )
                          assert not any(
                              isinstance(node.op, Elemwise)
                              for node in nodelst
                              if not isinstance(node.op, GpuElemwise)
                          )
                  results_gpu, results_cpu = outputs
                  utt.assert_allclose(results_gpu, results_cpu)
  
      # Make sure we test at least one case with no number of inputs overflow
      assert any(overflow >= 0 for overflow in nb_of_inputs_overflows)
  
      # Make sure we test at least one case with number of inputs overflow
      assert any(overflow < 0 for overflow in nb_of_inputs_overflows)
  
imports: from __future__ import absolute_import, print_function, division
  from nose.tools import assert_raises
  import numpy
  import theano
  from theano import tensor
  import theano.tensor.slinalg
  from theano.tests.breakpoint import PdbBreakpoint
  from theano.tests import unittest_tools, test_ifelse
  from theano.tensor.tests import test_basic
  from theano.gof.opt import check_stack_trace
  import theano.gpuarray
  from ..None import basic_ops
  from ..type import GpuArrayType, gpuarray_shared_constructor, get_context
  from ..basic_ops import GpuAlloc, GpuAllocEmpty, GpuReshape, GpuFromHost, HostFromGpu, host_from_gpu
  from ..blas import GpuGemm
  from ..elemwise import GpuCAReduceCuda, GpuCAReduceCPY, GpuElemwise, Elemwise, max_inputs_to_GpuElemwise
  from ..dnn import GpuDnnReduction
  from ..subtensor import GpuSubtensor
  from ..linalg import GpuCusolverSolve, cusolver_available, GpuCholesky
  from .config import mode_with_gpu, mode_without_gpu, test_ctx_name, SkipTest
  import unittest
  from theano.tensor.nnet import abstract_conv
  from theano.gpuarray import dnn, blas, opt
label_desc: Use image node_id 17 for calling a global function with example usage: test_many_arg_elemwise() without return types