class_docstr: This class computes the loss function for A2C with discrete action spaces.
class_docstr_tok: ["This","class","computes","the","loss","function","for","A2C","with","discrete","action","spaces","."]
code: def __call__(self, outputs, labels, weights):
      prob = outputs[self.action_prob_index]
      value = outputs[self.value_index]
      reward, advantage = weights
      action = labels[0]
      advantage = tf.expand_dims(advantage, axis=1)
      prob = prob + np.finfo(np.float32).eps
      log_prob = tf.math.log(prob)
      policy_loss = -tf.reduce_mean(
          advantage * tf.reduce_sum(action * log_prob, axis=1)
      )
      value_loss = tf.reduce_mean(tf.square(reward - value))
      entropy = -tf.reduce_mean(tf.reduce_sum(prob * log_prob, axis=1))
      return (
          policy_loss
          + self.value_weight * value_loss
          - self.entropy_weight * entropy
      )
  
imports: import time
  from collections.abc import Sequence
  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 A2CLossDiscrete obj's underlying member method code with example usage: obj.__call__(outputs, labels, weights) and returns: unknown