code: def main():
      env = gym.make("CartPole-v1")
      # Compatible for different versions of gym
      env = CompatWrapper(env)
      # env = env.unwrapped # Cancel the minimum score limit
      obs_dim = env.observation_space.shape[0]
      act_dim = env.action_space.n
      logger.info("obs_dim {}, act_dim {}".format(obs_dim, act_dim))
  
      # build an agent
      model = CartpoleModel(obs_dim=obs_dim, act_dim=act_dim)
      alg = parl.algorithms.PolicyGradient(model, lr=LEARNING_RATE)
      agent = CartpoleAgent(alg)
  
      # load model and evaluate
      # if os.path.exists('./model.ckpt'):
      #     agent.restore('./model.ckpt')
      #     run_evaluate_episodes(agent, env, render=True)
      #     exit()
  
      for i in range(args.max_episodes):
          obs_list, action_list, reward_list = run_train_episode(
              agent, env
          )
          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:
              total_reward = run_evaluate_episodes(agent, render=False)
              logger.info("Test reward: {}".format(total_reward))
  
      # save the parameters to ./model.ckpt
      agent.save("./model.ckpt")
  
file_path: PARL/examples/QuickStart/train.py
imports: import os
  import gym
  import numpy
  import parl
  from parl.utils import logger
  from parl.env import CompatWrapper, is_gym_version_ge
  from cartpole_model import CartpoleModel
  from cartpole_agent import CartpoleAgent
  import argparse
label_desc: Use image node_id 4 for calling a global function with example usage: main() without return types