def _find_bad_optimizations0(order, reasons, r_vals):
    # iterate over variables looking for values that don't match the
    # values of the variables they replaced.  This is the sign of a
    # broken optimization.
    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]:
                # check if the value for new_r doesn't match the value for 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'):
                    # This way will be deprecated later, but not right now
                    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.
dataset/ETHPy150Open rizar/attention-lvcsr/libs/Theano/theano/compile/debugmode.py/_find_bad_optimizations0