@register_canonicalize
    @gof.local_optimizer([T.Sum])
    def local_sum_over_empty(node):
        if isinstance(node.op, T.Sum):
            # This optimization needs ShapeOpt and fgraph.shape_feature
            if not hasattr(node.fgraph, 'shape_feature'):
                return
            y, = node.outputs
            y_shape = node.fgraph.shape_feature.shape_of[y]

            def tmp(thing):
                try:
                    return T.get_scalar_constant_value(thing)
                except (__HOLE__, ValueError) as e:
                    print(e, thing.owner.inputs[0])
                    return None
            print('LOCAL SUM EMPTY', [tmp(s) for s in y_shape])

##################
# Middleman cuts #
##################
dataset/ETHPy150Open rizar/attention-lvcsr/libs/Theano/theano/tensor/opt.py/local_sum_over_empty