class_docstr: trpo class
class_docstr_tok: ["trpo","class"]
docstr: pi gradients
  :param states: state batch
  :param actions: actions batch
  :param adv: advantage batch
  :param old_log_prob: old log probability batch
  :return: gradient
docstr_tok: ["pi","gradients",":","param","states",":","state","batch",":","param","actions",":","actions","batch",":","param","adv",":","advantage","batch",":","param","old_log_prob",":","old","log","probability","batch",":","return",":","gradient"]
code: def gradient(self, states, actions, adv, old_log_prob):
      """
      pi gradients
      :param states: state batch
      :param actions: actions batch
      :param adv: advantage batch
      :param old_log_prob: old log probability batch
      :return: gradient
      """
      pi_params = self.actor.trainable_weights
      with tf.GradientTape() as tape:
          loss = self.pi_loss(states, actions, adv, old_log_prob)
      grad = tape.gradient(loss, pi_params)
      gradient = self._flat_concat(grad)
      return gradient, loss
  
imports: import argparse
  import copy
  import os
  import threading
  import time
  import gym
  import matplotlib.pyplot
  import numpy
  import scipy.signal
  import tensorflow
  import tensorflow_probability
  import tensorlayer
label_desc: Use image node_id 4 for calling the TRPO obj's underlying member method code with example usage: obj.gradient(states, actions, adv, old_log_prob) and returns: gradient,  loss