Log-softmax over a given dimension.
Tensor logSoftmax(int dim) { final sm = softmax(dim); return sm.map((x) => math.log(x + 1e-10)); }