def collect_shared_vars(expressions):
 if isinstance(expressions, theano.Variable):
  expressions = [expressions]
 return [v for v in theano.gof.graph.inputs(reversed(expressions)) if isinstance(v, theano.compile.SharedVariable)]

def collect_shared_vars ( expressions ) : if isinstance ( expressions , theano . Variable ) : expressions = [ expressions ] return [ v for v in theano . gof . graph . inputs ( reversed ( expressions ) ) if isinstance ( v , theano . compile . SharedVariable ) ]
returns all shared variables the given expression(s) depend on .