code: def test_grad_disconnected(self):
      # tests corner cases of gradient for shape and alloc
  
      x = theano.tensor.vector(name="x")
      total = x.sum()
      total.name = "total"
      num_elements = x.shape[0]
      num_elements.name = "num_elements"
      silly_vector = theano.tensor.alloc(
          total / num_elements, num_elements
      )
      silly_vector.name = "silly_vector"
      cost = silly_vector.sum()
      cost.name = "cost"
      # note that cost simplifies to be the same as "total"
      g = gradient.grad(cost, x, add_names=False)
      # we still need to pass in x because it determines the shape of
      # the output
      f = theano.function([x], g)
      rng = np.random.RandomState([2012, 9, 5])
      x = np.cast[x.dtype](rng.randn(3))
      g = f(x)
      assert np.allclose(g, np.ones(x.shape, dtype=x.dtype))
  
imports: from __future__ import absolute_import, print_function, division
  from collections import OrderedDict
  import unittest
  import numpy
  from six.moves import xrange
  import theano
  from theano import gof, change_flags
  from theano.compat import izip
  from theano.tests import unittest_tools
  from theano import gradient
  from theano import config
  from theano.gof.null_type import NullType
  from theano.sandbox.rng_mrg import MRG_RandomStreams
label_desc: Use image node_id 13 for calling the test_grad obj's underlying member method code with example usage: obj.test_grad_disconnected() without return types