Implement a function to calculate the perplexity of a language model. **Example:** Given a language model and a test set, calculate the perplexity. **Constraints:** The language model and test set will be provided as input.
Test Cases
Test Case 1
Input:
{'I love': 0.5, 'love this': 0.3}, ['I love this', 'I love this']Expected:
2.0Test Case 2
Input:
{'This is': 0.2, 'is a': 0.4, 'a test': 0.1}, ['This is a test', 'This is a test']Expected:
5.0+ 3 hidden test cases