q_greater = tf.maximum(q, 0.0) // Greater of the exponent term or zero
scale = tf.exp(-q_greater)
a_scale = tf.exp(q-q_greater)
n = tf.mul(n, scale)+tf.mul(tf.mul(u, tf.nn.tanh(g)), a_scale)// Numerically stable update of numerator
d = tf.mul(d, scale)+a_scale // Numerically stable update of denominator
h_new = activation(tf.div(n, d))