def _find_bad_optimizations0(order, reasons, r_vals):
 for (i, node) in enumerate(order):
  for new_r in node.outputs:
   for (reason, r, old_graph_str, new_graph_str) in reasons[new_r]:
    new_r_val = r_vals[new_r]
    r_val = r_vals[r]
    assert (r.type == new_r.type)
    if hasattr(new_r.tag, 'values_eq_approx'):
     check = new_r.tag.values_eq_approx(r_val, new_r_val)
    elif hasattr(new_r, 'values_eq_approx'):
     check = new_r.values_eq_approx(r_val, new_r_val)
    else:
     check = r.type.values_eq_approx(r_val, new_r_val)
    if (not check):
     raise BadOptimization(old_r=r, new_r=new_r, old_r_val=r_val, new_r_val=new_r_val, reason=reason, old_graph=old_graph_str, new_graph=new_graph_str)

def _find_bad_optimizations0 ( order , reasons , r_vals ) : for ( i , node ) in enumerate ( order ) : for new_r in node . outputs : for ( reason , r , old_graph_str , new_graph_str ) in reasons [ new_r ] : new_r_val = r_vals [ new_r ] r_val = r_vals [ r ] assert ( r . type == new_r . type ) if hasattr ( new_r . tag , 'values_eq_approx' ) : check = new_r . tag . values_eq_approx ( r_val , new_r_val ) elif hasattr ( new_r , 'values_eq_approx' ) : check = new_r . values_eq_approx ( r_val , new_r_val ) else : check = r . type . values_eq_approx ( r_val , new_r_val ) if ( not check ) : raise BadOptimization ( old_r = r , new_r = new_r , old_r_val = r_val , new_r_val = new_r_val , reason = reason , old_graph = old_graph_str , new_graph = new_graph_str )
use a simple algorithm to find broken optimizations .