code: def normal_kl(mean1, logvar1, mean2, logvar2):
      """
      Compute the KL divergence between two gaussians.
  
      Shapes are automatically broadcasted, so batches can be compared to
      scalars, among other use cases.
      """
      tensor = None
      for obj in (mean1, logvar1, mean2, logvar2):
          if isinstance(obj, paddle.Tensor):
              tensor = obj
              break
      assert (
          tensor is not None
      ), "at least one argument must be a Tensor"
  
      # Force variances to be Tensors. Broadcasting helps convert scalars to
      # Tensors, but it does not work for th.exp().
      logvar1, logvar2 = [
          x if isinstance(x, paddle.Tensor) else paddle.to_tensor(x)
          for x in (logvar1, logvar2)
      ]
  
      return 0.5 * (
          -1.0
          + logvar2
          - logvar1
          + paddle.exp(logvar1 - logvar2)
          + ((mean1 - mean2) ** 2) * paddle.exp(-logvar2)
      )
  
file_path: PaddleHub/modules/image/text_to_image/disco_diffusion_clip_rn101/reverse_diffusion/model/losses.py
imports: import numpy
  import paddle
  import paddle.nn.functional
label_desc: Use image node_id 1 for calling a global function with example usage: normal_kl(mean1, logvar1, mean2, logvar2) and returns: unknown