How Tensorflow text prediction predicts without softmax activation
The logits have the distribution according to the len of vocabulary and the model training. So, you can use np.argmax(logits) to get the prediction, but normally to the application of generating script is more interesting to take into account a factor of aleatory which in this case is the function "random_categorical" which is used to get the value according to the probability. The value 29 appears in the distribution, you didn't see, because you execute the function a lot of times and every execution, "random values" will appear. If you want the exact value, use np.argmax.