code: def run_train_episode(agent, env, rpm):
      obs = env.reset()
      total_reward = 0
      steps = 0
      while True:
          steps += 1
          batch_obs = np.expand_dims(obs, axis=0)
          action = agent.sample(batch_obs.astype("float32"))
          action = action[0]  # ContinuousCartPoleE输入的action为一个实数
  
          next_obs, reward, done, info = env.step(action)
  
          action = [action]  # 方便存入replaymemory
          rpm.append(
              (obs, action, REWARD_SCALE * reward, next_obs, done)
          )
  
          if len(rpm) > MEMORY_WARMUP_SIZE and (steps % 5) == 0:
              (
                  batch_obs,
                  batch_action,
                  batch_reward,
                  batch_next_obs,
                  batch_done,
              ) = rpm.sample(BATCH_SIZE)
              agent.learn(
                  batch_obs,
                  batch_action,
                  batch_reward,
                  batch_next_obs,
                  batch_done,
              )
  
          obs = next_obs
          total_reward += reward
  
          if done or steps >= 200:
              break
      return total_reward
  
file_path: PARL/examples/tutorials/parl2_dygraph/lesson5/ddpg/train.py
imports: import gym
  import parl
  import paddle
  import numpy
  from parl.utils import logger
  from agent import Agent
  from model import Model
  from algorithm import DDPG
  from env import ContinuousCartPoleEnv
  from replay_memory import ReplayMemory
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