code: def test_opfromgraph(self):
      # as with the scan tests above, insert foreign inputs into the
      # inner graph.
      outer = tensor.scalar("outer")
      shared = theano.shared(
          np.array(1.0, dtype=theano.config.floatX), name="shared"
      )
      constant = tensor.constant(1.0, name="constant")
      z = outer * (shared + constant)
  
      # construct the inner graph
      a = tensor.scalar()
      b = tensor.scalar()
      r = a + b
      r.tag.replacement = z * (a - b)
  
      # construct the outer graph
      c = tensor.scalar()
      d = tensor.scalar()
      u = theano.OpFromGraph([a, b], [r])(c, d)
      t = z * u
      (v,) = map_variables(self.replacer, [t])
      t2 = z * v
  
      f = theano.function([c, d, outer], [t, t2])
      for m, n in itertools.combinations(range(10), 2):
          assert f(m, n, outer=0.5) == [m + n, m - n]
  
      # test that the unsupported case of replacement with a shared
      # variable with updates crashes
      shared.update = shared + 1
      self.assertRaises(
          NotImplementedError, map_variables, self.replacer, [t]
      )
  
file_path: Theano/theano/scan_module/tests/test_scan_utils.py
imports: from __future__ import absolute_import, print_function, division
  import itertools
  import unittest
  import numpy
  import theano
  from theano import tensor
  from theano.scan_module.scan_utils import equal_computations, map_variables
  from theano.tensor.type_other import NoneConst
label_desc: Use image node_id 7 for calling the TestMapVariables obj's underlying member method code with example usage: obj.test_opfromgraph() without return types