def replace_params_with_consts(expr):
 if (expr.type == lo.PARAM):
  return create_const(check_param_val(expr.data), expr.size)
 else:
  new_args = []
  for arg in expr.args:
   new_args.append(replace_params_with_consts(arg))
  if (isinstance(expr.data, lo.LinOp) and (expr.data.type == lo.PARAM)):
   data_lin_op = expr.data
   val = check_param_val(data_lin_op.data)
   data = create_const(val, data_lin_op.size)
  else:
   data = expr.data
  return lo.LinOp(expr.type, expr.size, new_args, data)

def replace_params_with_consts ( expr ) : if ( expr . type == lo . PARAM ) : return create_const ( check_param_val ( expr . data ) , expr . size ) else : new_args = [ ] for arg in expr . args : new_args . append ( replace_params_with_consts ( arg ) ) if ( isinstance ( expr . data , lo . LinOp ) and ( expr . data . type == lo . PARAM ) ) : data_lin_op = expr . data val = check_param_val ( data_lin_op . data ) data = create_const ( val , data_lin_op . size ) else : data = expr . data return lo . LinOp ( expr . type , expr . size , new_args , data )
replaces parameters with constant nodes .