code: def main():
      env = gym.make("CartPole-v0")
      model = CartpoleModel(act_dim=ACT_DIM)
      alg = parl.algorithms.PolicyGradient(model, lr=LEARNING_RATE)
      agent = CartpoleAgent(alg, obs_dim=OBS_DIM, act_dim=ACT_DIM)
  
      # if the file already exists, restore parameters from it
      if os.path.exists("./model_dir"):
          agent.restore("./model_dir")
  
      for i in range(1000):
          obs_list, action_list, reward_list = run_episode(env, agent)
          if i % 10 == 0:
              logger.info(
                  "Episode {}, Reward Sum {}.".format(
                      i, sum(reward_list)
                  )
              )
  
          batch_obs = np.array(obs_list)
          batch_action = np.array(action_list)
          batch_reward = calc_reward_to_go(reward_list)
  
          agent.learn(batch_obs, batch_action, batch_reward)
          if (i + 1) % 100 == 0:
              _, _, reward_list = run_episode(
                  env, agent, train_or_test="test"
              )
              total_reward = np.sum(reward_list)
              logger.info("Test reward: {}".format(total_reward))
  
      # save the parameters to ./model_dir
      agent.save("./model_dir")
  
file_path: PARL/benchmark/fluid/QuickStart/train.py
imports: from parl.utils import check_version_for_fluid
  import gym
  import numpy
  import parl
  import os.path
  from cartpole_agent import CartpoleAgent
  from cartpole_model import CartpoleModel
  from parl.utils import logger
label_desc: Use image node_id 3 for calling a global function with example usage: main() without return types