code: def finalize_episode(self, params):
          
          total_reward = sum(self.intermediate_rewards)
          self.total_rewards.append(total_reward)
          self.params.append(params)
          self.intermediate_rewards = []
docs: 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()