https://noisrucer.github.io/posts/4_1_Stabilizing_softmax_logsoftmax/
Stabilizing Softmax and Logsoftmax functions to avoid underflow and overflow - noisrucer