class_docstr: Categorical distribution for discrete action spaces.
class_docstr_tok: ["Categorical","distribution","for","discrete","action","spaces","."]
docstr: Args:
      other: object of CategoricalDistribution
  
  Returns:
      kl: A float32 tensor with shape [BATCH_SIZE]
docstr_tok: ["Args",":","other",":","object","of","CategoricalDistribution","Returns",":","kl",":","A","float32","tensor","with","shape","[","BATCH_SIZE","]"]
code: def kl(self, other):
      """
      Args:
          other: object of CategoricalDistribution
  
      Returns:
          kl: A float32 tensor with shape [BATCH_SIZE]
      """
      assert isinstance(other, CategoricalDistribution)
  
      logits = self.logits - paddle.max(
          self.logits, axis=1, keepdim=True
      )
      other_logits = other.logits - paddle.max(
          other.logits, axis=1, keepdim=True
      )
  
      e_logits = paddle.exp(logits)
      other_e_logits = paddle.exp(other_logits)
  
      z = paddle.sum(e_logits, axis=1, keepdim=True)
      other_z = paddle.sum(other_e_logits, axis=1, keepdim=True)
  
      prob = e_logits / z
      kl = paddle.sum(
          prob
          * (
              logits
              - paddle.log(z)
              - other_logits
              + paddle.log(other_z)
          ),
          axis=1,
      )
      return kl
  
imports: import paddle
  import paddle.nn.functional
  import numpy
label_desc: Use image node_id 5 for calling the CategoricalDistribution obj's underlying member method code with example usage: obj.kl(other) and returns: kl