def recursive_set_rng_kwarg(expr, rng=None):
 if (rng is None):
  rng = np.random.RandomState()
 lrng = as_apply(rng)
 for node in dfs(expr):
  if (node.name in implicit_stochastic_symbols):
   for (ii, (name, arg)) in enumerate(list(node.named_args)):
    if (name == 'rng'):
     node.named_args[ii] = ('rng', lrng)
     break
   else:
    node.named_args.append(('rng', lrng))
 return expr

def recursive_set_rng_kwarg ( expr , rng = None ) : if ( rng is None ) : rng = np . random . RandomState ( ) lrng = as_apply ( rng ) for node in dfs ( expr ) : if ( node . name in implicit_stochastic_symbols ) : for ( ii , ( name , arg ) ) in enumerate ( list ( node . named_args ) ) : if ( name == 'rng' ) : node . named_args [ ii ] = ( 'rng' , lrng ) break else : node . named_args . append ( ( 'rng' , lrng ) ) return expr
make all of the stochastic nodes in expr use the rng uniform -> uniform .