code: def run_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.predict(batch_obs.astype("float32"))
  
          # 增加探索扰动, 输出限制在 [-1.0, 1.0] 范围内
          action = np.clip(np.random.normal(action, NOISE), -1.0, 1.0)
  
          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/lesson5/ddpg/train.py
imports: import gym
  import parl
  import paddle
  import gym
  import numpy
  import parl
  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_episode(agent, env, rpm) and returns: total_reward