Finally, I think, dealt with the np.inf problem in the perplexity script.