code: def _main(_):
      env = gym.make("CartPole-v0")
      env = env.unwrapped
  
      env_config = tx.agents.get_gym_env_config(env)
      agent = PGAgent(
          env_config,
          policy_kwargs={"action_space": env_config.action_space},
          hparams=config.pg_agent_hparams,
      )
  
      sess = tf.Session()
      agent.sess = sess
      sess.run(tf.global_variables_initializer())
      sess.run(tf.local_variables_initializer())
      sess.run(tf.tables_initializer())
      feed_dict = {tx.global_mode(): tf.estimator.ModeKeys.TRAIN}
  
      for e in range(300):
          reward_sum = 0.0
          observ = env.reset()
          agent.reset()
          while True:
              action = agent.get_action(observ, feed_dict=feed_dict)
  
              next_observ, reward, terminal, _ = env.step(action=action)
              if terminal:
                  reward = 0.0
              agent.observe(reward, terminal, feed_dict=feed_dict)
              observ = next_observ
  
              reward_sum += reward
              if terminal:
                  break
  
          if (e + 1) % 10 == 0:
              print("episode {}: {}".format(e + 1, reward_sum))
  
      sess.close()
  
imports: import importlib
  import gym
  import tensorflow
  import texar.tf
  from texar.tf.agents import PGAgent
label_desc: Use image node_id 1 for calling a global function with example usage: _main(_) without return types