code: def forced_replace(out, x, y):
      """
      Check all internal values of the graph that compute the variable ``out``
      for occurrences of values identical with ``x``. If such occurrences are
      encountered then they are replaced with variable ``y``.
  
      Parameters
      ----------
      out : Theano Variable
      x : Theano Variable
      y : Theano Variable
  
      Examples
      --------
      out := sigmoid(wu)*(1-sigmoid(wu))
      x := sigmoid(wu)
      forced_replace(out, x, y) := y*(1-y)
  
      Note
      ----
      When it find a match, it don't continue on the corresponding inputs.
      """
      if out is None:
          return None
  
      # ``visited`` is a set of nodes that are already known and don't need to be
      # checked again, speeding up the traversal of multiply-connected graphs.
      visited = set()
      from collections import deque
  
      q = deque()
      q.append(out)
      to_replace = []
      while q:
          graph = q.popleft()
          if graph in visited:
              continue
          visited.add(graph)
          if equal_computations([graph], [x]):
              to_replace.append((graph, y))
          elif graph.owner:
              q.extendleft(graph.owner.inputs)
  
      if len(to_replace) == 0:
          return out
      return clone(out, replace=to_replace)
  
imports: from __future__ import absolute_import, print_function, division
  import copy
  import logging
  import warnings
  from collections import OrderedDict
  import numpy
  import theano
  from theano.compat import izip
  from six import string_types, iteritems
  from six.moves import xrange
  from theano.compile.pfunc import rebuild_collect_shared
  from theano import gof, compat
  from theano import tensor, scalar
  from theano.tensor.basic import get_scalar_constant_value
label_desc: Use image node_id 15 for calling a global function with example usage: forced_replace(out, x, y) and returns: clone, None, out