code: def run_episode(agent, env, rpm):
      total_reward = 0
      obs = env.reset()
      step = 0
      while True:
          step += 1
          action = agent.sample(obs)
          next_obs, reward, isOver, _ = env.step(action)
          rpm.append((obs, action, reward, next_obs, isOver))
  
          # train model
          if (len(rpm) > MEMORY_WARMUP_SIZE) and (
              step % LEARN_FREQ == 0
          ):
              (
                  batch_obs,
                  batch_action,
                  batch_reward,
                  batch_next_obs,
                  batch_isOver,
              ) = rpm.sample(BATCH_SIZE)
              train_loss = agent.learn(
                  batch_obs,
                  batch_action,
                  batch_reward,
                  batch_next_obs,
                  batch_isOver,
              )
  
          total_reward += reward
          obs = next_obs
          if isOver:
              break
      return total_reward
  
file_path: PARL/benchmark/fluid/DQN/train_with_xpu.py
imports: import os
  import gym
  import numpy
  import paddle
  import parl
  from parl.utils import logger, check_version_for_xpu
  from cartpole_model import CartpoleModel
  from cartpole_agent import CartpoleAgent
  from replay_memory import ReplayMemory
label_desc: Use image node_id 1 for calling a global function with example usage: run_episode(agent, env, rpm) and returns: total_reward