def forced_replace(out, x, y):
 if (out is None):
  return None
 visited = set()
 def local_traverse(graph, x):
  if (graph in visited):
   return []
  visited.add(graph)
  if equal_computations([graph], [x]):
   return [graph]
  elif (not graph.owner):
   return []
  else:
   rval = []
   for inp in graph.owner.inputs:
    rval += local_traverse(inp, x)
   return rval
 to_replace = local_traverse(out, x)
 return clone(out, replace=OrderedDict(((v, y) for v in to_replace)))

def forced_replace ( out , x , y ) : if ( out is None ) : return None visited = set ( ) def local_traverse ( graph , x ) : if ( graph in visited ) : return [ ] visited . add ( graph ) if equal_computations ( [ graph ] , [ x ] ) : return [ graph ] elif ( not graph . owner ) : return [ ] else : rval = [ ] for inp in graph . owner . inputs : rval += local_traverse ( inp , x ) return rval to_replace = local_traverse ( out , x ) return clone ( out , replace = OrderedDict ( ( ( v , y ) for v in to_replace ) ) )
check all internal values of the graph that compute the variable out for occurrences of values identical with x .