To get the predictions from our model, we need to take a sample from the output distribution. This sampling will get us the characters we need from that output distribution (sampling the output distribution is important because taking the argmax of it, as we would normally do, can easily get the model stuck in a loop).
tf.random.categorical does this sampling and tf.squeeze with axis=-1 removes the last dimension of the tensor, prior to displaying the indices.
The signature of tf.random.categorical is as follows:
tf.random.categorical(logits, num_samples, seed=None, name=None, output_dtype=None)
Comparing this with the call, we see that we are taking one sample (of length sequence_length = 100) from the predictions (example_batch_predictions[0]). The extra dimension is then removed, so we can look up the characters corresponding to the sample...