code: def test_downcast_dtype(self):
      # Test that the gradient of a cost wrt a float32 variable does not
      # get upcasted to float64.
      # x has dtype float32, regardless of the value of floatX
      x = theano.tensor.fscalar("x")
      y = x * 2
      z = theano.tensor.lscalar("z")
  
      c = y + z
      dc_dx, dc_dy, dc_dz, dc_dc = theano.grad(c, [x, y, z, c])
      # The dtype of dc_dy and dc_dz can be either float32 or float64,
      # that might depend on floatX, but is not specified.
      assert dc_dc.dtype in ("float32", "float64")
      assert dc_dz.dtype in ("float32", "float64")
      assert dc_dy.dtype in ("float32", "float64")
  
      # When the output gradient of y is passed to op.grad, it should
      # be downcasted to float32, so dc_dx should also be float32
      assert dc_dx.dtype == "float32"
  
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 15 for calling the test_grad obj's underlying member method code with example usage: obj.test_downcast_dtype() without return types