I think np.prod(res.shape) is equivalent to res.size