def backward(self, inputs, grads): xp = cuda.get_array_module(*inputs) x, = inputs gy, = grads y = self.y gx = gy * xp.exp(x) * xp.cumsum(xp.exp(-y), axis=0) return gx,