The same accuracy and behavior can be achieved by using a simple mathematical transformation that eliminates $\mathrm{tahn}$$\mathrm{tanh}$, and considering that GPUs typically offer a fused multiply-add (FMA) as well as a fast reciprocal, which one would want to utilize. Exemplary CUDA code looks as follows: