code: def run_train_episode(env, agent, rpm):
      total_reward = 0
      all_cost = []
      obs = env.reset()
      steps = 0
      while True:
          steps += 1
          context = rpm.recent_obs()
          context.append(obs)
          context = np.stack(context, axis=0)
          action = agent.sample(context)
          next_obs, reward, isOver, _ = env.step(action)
          rpm.append(Experience(obs, action, reward, isOver))
          # start training
          if rpm.size() > MEMORY_WARMUP_SIZE:
              if steps % UPDATE_FREQ == 0:
                  (
                      batch_all_obs,
                      batch_action,
                      batch_reward,
                      batch_isOver,
                  ) = rpm.sample_batch(args.batch_size)
                  batch_obs = batch_all_obs[:, :CONTEXT_LEN, :, :]
                  batch_next_obs = batch_all_obs[:, 1:, :, :]
                  cost = agent.learn(
                      batch_obs,
                      batch_action,
                      batch_reward,
                      batch_next_obs,
                      batch_isOver,
                  )
                  all_cost.append(float(cost))
          total_reward += reward
          obs = next_obs
          if isOver:
              break
      if all_cost:
          logger.info(
              "[Train]total_reward: {}, mean_cost: {}".format(
                  total_reward, np.mean(all_cost)
              )
          )
      return total_reward, steps, np.mean(all_cost)
  
file_path: PARL/benchmark/fluid/DQN_variant/train.py
imports: from parl.utils import check_version_for_fluid
  import argparse
  import gym
  import paddle.fluid
  import numpy
  import os
  import parl
  from atari_agent import AtariAgent
  from atari_model import AtariModel
  from datetime import datetime
  from replay_memory import ReplayMemory, Experience
  from parl.utils import summary, logger
  from tqdm import tqdm
  from utils import get_player
label_desc: Use image node_id 1 for calling a global function with example usage: run_train_episode(env, agent, rpm) and returns: total_reward,  steps,  np