def view_roots(r):
 owner = r.owner
 if (owner is not None):
  try:
   view_map = owner.op.view_map
   view_map = dict(((owner.outputs[o], i) for (o, i) in iteritems(view_map)))
  except AttributeError:
   return [r]
  if (r in view_map):
   answer = []
   for i in view_map[r]:
    answer += view_roots(owner.inputs[i])
   return answer
  else:
   return [r]
 else:
  return [r]

def view_roots ( r ) : owner = r . owner if ( owner is not None ) : try : view_map = owner . op . view_map view_map = dict ( ( ( owner . outputs [ o ] , i ) for ( o , i ) in iteritems ( view_map ) ) ) except AttributeError : return [ r ] if ( r in view_map ) : answer = [ ] for i in view_map [ r ] : answer += view_roots ( owner . inputs [ i ] ) return answer else : return [ r ] else : return [ r ]
utility function that returns the leaves of a search through consecutive view_map()s .