I am currently training a language model and in order to evaluate it, I have written the function given below to calculate the perplexity of the test set,
def