def _last_index(self, s):
        self.set_index(max(0, self._find_one_after_last_labeled_index() - 1))
def f(i):
        start = W[i]
        extent = W[i + 1] - W[i]
        rv = te.reduce_axis((0, extent))
        return te.sum(X[rv + start], axis=rv)