Simplest measure of perplexity with available models?

I want a measure of perplexity for each token in a string like in the research doc “Perplexity of Fixed Length Models” by @joeddav.

What is the quickest way to accomplish for testing an idea? Is there some way to do it via the Inference API?