code: def run_train_episode(agent, env, rpm):
      total_reward = 0
      obs = env.reset()
      step = 0
      while True:
          step += 1
          action = agent.sample(obs)
          next_obs, reward, done, _ = env.step(action)
          rpm.append(obs, action, reward, next_obs, done)
          # train model
          if (len(rpm) > MEMORY_WARMUP_SIZE) and (
              step % LEARN_FREQ == 0
          ):
              # s,a,r,s',done
              (
                  batch_obs,
                  batch_action,
                  batch_reward,
                  batch_next_obs,
                  batch_done,
              ) = rpm.sample_batch(BATCH_SIZE)
              train_loss = agent.learn(
                  batch_obs,
                  batch_action,
                  batch_reward,
                  batch_next_obs,
                  batch_done,
              )
  
          total_reward += reward
          obs = next_obs
          if done:
              break
      return total_reward
  
file_path: PARL/examples/DQN/train.py
imports: import os
  import gym
  import numpy
  import parl
  import argparse
  from parl.utils import logger, ReplayMemory
  from cartpole_model import CartpoleModel
  from cartpole_agent import CartpoleAgent
  from parl.env import CompatWrapper, is_gym_version_ge
  from parl.algorithms import DQN
label_desc: Use image node_id 1 for calling a global function with example usage: run_train_episode(agent, env, rpm) and returns: total_reward