def pre_constant_merge(vars):
 seen_var = set()
 const_sig_inv = {}
 if isinstance(vars, graph.Variable):
  vars = [vars]
 def recursive_merge(var):
  if (var in seen_var):
   return var
  if (not hasattr(var, 'owner')):
   return var
  if (var.owner and hasattr(var.owner, 'fgraph')):
   return var
  seen_var.add(var)
  if isinstance(var, graph.Constant):
   sig = var.signature()
   try:
    if (sig in const_sig_inv):
     return const_sig_inv[sig]
    const_sig_inv[sig] = var
   except TypeError:
    warnings.warn(("We work around a problem, the following variable signature isn't hashable. Please, report this to theano-dev so that the better fix is done. %s" % var))
    pass
   return var
  if var.owner:
   for (idx, inp) in enumerate(var.owner.inputs):
    var.owner.inputs[idx] = recursive_merge(inp)
  return var
 return list(map(recursive_merge, vars))

def pre_constant_merge ( vars ) : seen_var = set ( ) const_sig_inv = { } if isinstance ( vars , graph . Variable ) : vars = [ vars ] def recursive_merge ( var ) : if ( var in seen_var ) : return var if ( not hasattr ( var , 'owner' ) ) : return var if ( var . owner and hasattr ( var . owner , 'fgraph' ) ) : return var seen_var . add ( var ) if isinstance ( var , graph . Constant ) : sig = var . signature ( ) try : if ( sig in const_sig_inv ) : return const_sig_inv [ sig ] const_sig_inv [ sig ] = var except TypeError : warnings . warn ( ( "We work around a problem, the following variable signature isn't hashable. Please, report this to theano-dev so that the better fix is done. %s" % var ) ) pass return var if var . owner : for ( idx , inp ) in enumerate ( var . owner . inputs ) : var . owner . inputs [ idx ] = recursive_merge ( inp ) return var return list ( map ( recursive_merge , vars ) )
merge constants in the subgraph used to compute nodes in vars .