code: def test_disconnected_nan(self):
      # test that connection_pattern can prevent getting NaN
  
      # Op1 has two outputs, f and g
      # x is connected to f but not to g
      class Op1(theano.gof.Op):
          __props__ = ()
  
          def make_node(self, x):
              return theano.Apply(
                  self,
                  inputs=[x],
                  outputs=[x.type(), theano.tensor.scalar()],
              )
  
          def connection_pattern(self, node):
              return [[True, False]]
  
          def grad(self, inputs, output_grads):
              return [inputs[0].zeros_like()]
  
      # Op2 has two inputs, f and g
      # Its gradient with respect to g is not defined
      class Op2(theano.gof.Op):
          __props__ = ()
  
          def make_node(self, f, g):
              return theano.Apply(
                  self, inputs=[f, g], outputs=[theano.tensor.scalar()]
              )
  
          def grad(self, inputs, output_grads):
              return [inputs[0].zeros_like(), NullType()()]
  
      x = theano.tensor.vector()
      f, g = Op1()(x)
      cost = Op2()(f, g)
  
      # cost is differentiable wrt x
      # but we can't tell that without using Op1's connection pattern
      # looking at the theano graph alone, g is an ancestor of cost
      # and has x as an ancestor, so we must compute its gradient
  
      g = gradient.grad(cost, x)
  
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 14 for calling the test_grad obj's underlying member method code with example usage: obj.test_disconnected_nan() and returns: theano, list, list, theano, list