class_docstr: This class computes the loss function for PPO.
class_docstr_tok: ["This","class","computes","the","loss","function","for","PPO","."]
code: def __call__(self, outputs, labels, weights):
      prob = outputs[self.action_prob_index]
      value = outputs[self.value_index]
      reward, advantage, old_prob = weights
      action = labels[0]
      advantage = tf.expand_dims(advantage, axis=1)
      machine_eps = np.finfo(np.float32).eps
      prob += machine_eps
      old_prob += machine_eps
      ratio = tf.reduce_sum(action * prob, axis=1) / old_prob
      clipped_ratio = tf.clip_by_value(
          ratio, 1 - self.clipping_width, 1 + self.clipping_width
      )
      policy_loss = -tf.reduce_mean(
          tf.minimum(ratio * advantage, clipped_ratio * advantage)
      )
      value_loss = tf.reduce_mean(tf.square(reward - value))
      entropy = -tf.reduce_mean(
          tf.reduce_sum(prob * tf.math.log(prob), axis=1)
      )
      return (
          policy_loss
          + self.value_weight * value_loss
          - self.entropy_weight * entropy
      )
  
imports: import copy
  import time
  from collections.abc import Sequence
  from multiprocessing.dummy import Pool
  import numpy
  import tensorflow
  from deepchem.models import KerasModel
  from deepchem.models.optimizers import Adam
label_desc: Use image node_id 2 for calling the PPOLoss obj's underlying member method code with example usage: obj.__call__(outputs, labels, weights) and returns: unknown