@register_uncanonicalize
@gof.local_optimizer([T.neg])
def local_max_to_min(node):
    if node.op == T.neg and node.inputs[0].owner:
        max = node.inputs[0]
        if (max.owner and
                isinstance(max.owner.op, CAReduce) and
                max.owner.op.scalar_op == scal.maximum):
            neg = max.owner.inputs[0]
            if neg.owner and neg.owner.op == T.neg:
                return [CAReduce(scal.minimum,
                                 max.owner.op.axis)(neg.owner.inputs[0])]

    return False
Change -(max(-x)) to min.
dataset/ETHPy150Open rizar/attention-lvcsr/libs/Theano/theano/tensor/opt_uncanonicalize.py/local_max_to_min