code: def test_grad_lazy_if(self):
      # Tests that we can compute the gradients through lazy if
      x = tensor.vector("x", dtype=self.dtype)
      y = tensor.vector("y", dtype=self.dtype)
      c = tensor.iscalar("c")
      z = ifelse(c, x, y)
      gx, gy = tensor.grad(z.sum(), [x, y])
  
      f = theano.function(
          [c, x, y],
          [self.cast_output(gx), self.cast_output(gy)],
          mode=self.mode,
      )
      # There is only 2 of the 3 ifelse that are moved on the GPU.
      # The one that stay on the CPU is for the shape.
      self.assertFunctionContains(f, self.get_ifelse(1), min=2, max=3)
      rng = np.random.RandomState(utt.fetch_seed())
  
      xlen = rng.randint(200)
      ylen = rng.randint(200)
  
      vx = np.asarray(rng.uniform(size=(xlen,)), self.dtype)
      vy = np.asarray(rng.uniform(size=(ylen,)), self.dtype)
      gx0, gy0 = f(1, vx, vy)
      assert np.allclose(gx0.shape, vx.shape)
      assert np.allclose(gy0.shape, vy.shape)
      assert np.all(np.asarray(gx0) == 1.0)
      assert np.all(np.asarray(gy0) == 0.0)
  
      gx0, gy0 = f(0, vx, vy)
      assert np.allclose(gx0.shape, vx.shape)
      assert np.allclose(gy0.shape, vy.shape)
      assert np.all(np.asarray(gx0) == 0.0)
      assert np.all(np.asarray(gy0) == 1.0)
  
imports: from __future__ import absolute_import, print_function, division
  import unittest
  import numpy
  from nose.plugins.skip import SkipTest
  from six.moves import reduce
  import theano
  from theano import tensor
  import theano.ifelse
  from theano.ifelse import IfElse, ifelse
  from theano.tests import unittest_tools
label_desc: Use image node_id 6 for calling the test_ifelse obj's underlying member method code with example usage: obj.test_grad_lazy_if() without return types