You implement four functions in three graded parts, in NumPy, not PyTorch, in a notebook that already defines softmax and comes with tests you have to pass. Part 3 builds on Part 2: Part 1 — Top-p sampling. top_p_filter(logits, p) keeps the smallest set of most-probable tokens whose total probability…