<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def finalize_episode(self, params):
 """Closes the current episode, sums up rewards and stores the parameters # Argument params (object):
 Parameters associated with the episode to be stored and then retrieved back in sample() """

        total_reward = sum(self.intermediate_rewards)
        self.total_rewards.append(total_reward)
        self.params.append(params)
        self.intermediate_rewards = []