class_docstr: Categorical distribution for discrete action spaces.
class_docstr_tok: ["Categorical","distribution","for","discrete","action","spaces","."]
docstr: Args:
      actions: An int64 tensor with shape [BATCH_SIZE]
      eps: A small float constant that avoids underflows when computing the log probability
  
  Returns:
      actions_log_prob: A float32 tensor with shape [BATCH_SIZE]
docstr_tok: ["Args",":","actions",":","An","int64","tensor","with","shape","[","BATCH_SIZE","]","eps",":","A","small","float","constant","that","avoids","underflows","when","computing","the","log","probability","Returns",":","actions_log_prob",":","A","float32","tensor","with","shape","[","BATCH_SIZE","]"]
code: def logp(self, actions, eps=1e-6):
      """
      Args:
          actions: An int64 tensor with shape [BATCH_SIZE]
          eps: A small float constant that avoids underflows when computing the log probability
  
      Returns:
          actions_log_prob: A float32 tensor with shape [BATCH_SIZE]
      """
      assert len(actions.shape) == 1
  
      logits = self.logits - paddle.max(
          self.logits, axis=1, keepdim=True
      )
      e_logits = paddle.exp(logits)
      z = paddle.sum(e_logits, axis=1, keepdim=True)
      prob = e_logits / z
  
      actions_onehot = F.one_hot(actions, prob.shape[1])
      actions_onehot = paddle.cast(actions_onehot, dtype="float32")
      actions_prob = prob * actions_onehot
      actions_prob = paddle.max(actions_prob, axis=1)
  
      actions_prob = actions_prob + eps
      actions_log_prob = paddle.log(actions_prob)
  
      return actions_log_prob
  
imports: import paddle
  import paddle.nn.functional
  import numpy
label_desc: Use image node_id 4 for calling the CategoricalDistribution obj's underlying member method code with example usage: obj.logp(actions, eps) and returns: actions_log_prob