class_docstr: PG class
docstr: update policy parameters via stochastic gradient ascent
  :return: None
docstr_tok: ["update","policy","parameters","via","stochastic","gradient","ascent",":","return",":","None"]
code: def learn(self):
      """
      update policy parameters via stochastic gradient ascent
      :return: None
      """
      discounted_reward_buffer_norm = self._discount_and_norm_rewards()
  
      with tf.GradientTape() as tape:
          _logits = self.model(np.vstack(self.state_buffer))
          neg_log_prob = tf.nn.sparse_softmax_cross_entropy_with_logits(
              logits=_logits, labels=np.array(self.action_buffer)
          )
          loss = tf.reduce_mean(
              neg_log_prob * discounted_reward_buffer_norm
          )
  
      grad = tape.gradient(loss, self.model.trainable_weights)
      self.optimizer.apply_gradients(
          zip(grad, self.model.trainable_weights)
      )
  
      self.state_buffer, self.action_buffer, self.reward_buffer = (
          [],
          [],
          [],
      )  # empty episode data
      return discounted_reward_buffer_norm
  
file_path: TensorLayer/examples/reinforcement_learning/tutorial_PG.py
imports: import argparse
  import os
  import time
  import gym
  import matplotlib.pyplot
  import numpy
  import tensorflow
  import tensorlayer
label_desc: Use image node_id 4 for calling the PolicyGradient obj's underlying member method code with example usage: obj.learn() and returns: discounted_reward_buffer_norm