code: def test_not_useless_scalar_gpuelemwise():
      # We don't want to move elemwise on scalar on the GPU when the
      # result will not be used on the GPU!
  
      with theano.change_flags(warn_float64="ignore"):
          X = tensor.fmatrix()
          x = np.random.randn(32, 32).astype(np.float32)
          m1 = theano.shared(np.random.randn(32, 32).astype(np.float32))
          loss = (X - tensor.dot(X, m1)).norm(L=2)
          lr = theano.shared(np.asarray(0.001, dtype=np.float32))
          grad = tensor.grad(loss, m1)
  
          train = theano.function(
              inputs=[X],
              updates=[(m1, m1 - lr * grad)],
              mode=mode_with_gpu,
          )
          train(x)
          topo = train.maker.fgraph.toposort()
          gemms = [app for app in topo if isinstance(app.op, GpuGemm)]
          assert len(gemms) == 2
          assert isinstance(
              gemms[1].inputs[1].owner.op, tensor.Elemwise
          )
  
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 18 for calling a global function with example usage: test_not_useless_scalar_gpuelemwise() without return types