Implement a Generalized Policy Iteration (GPI) simulator for finite Markov Decision Processes.
GPI is the overarching idea in reinforcement learning where policy evaluation and policy improvement alternate and interact. Unlike pure policy iteration (which runs evaluation to convergence before improving) or pure value iteration (which does a single evaluation backup), GPI allows a configurable number of evaluation sweeps between improvement steps.
Your function should:
The value update for a state s under action a follows the Bellman expectation equation using the full transition and reward model.
Args: