In the "Write With Transformer" page, how do different suggestions are selected?

When using Write With Transformer, after hitting tab, there are multiple suggestions. Sometimes one word, sometimes a partial sentence. How are these selected? In particular, for one word, does it take the top k probabilities from the output? When does it decide to continue to a sentence?

No answer from anyone?

Maybe link to the source code of the suggestion generation?