code: def discretized_gaussian_log_likelihood(x, *, means, log_scales):
      """
      Compute the log-likelihood of a Gaussian distribution discretizing to a
      given image.
  
      :param x: the target images. It is assumed that this was uint8 values,
                rescaled to the range [-1, 1].
      :param means: the Gaussian mean Tensor.
      :param log_scales: the Gaussian log stddev Tensor.
      :return: a tensor like x of log probabilities (in nats).
      """
      assert x.shape == means.shape == log_scales.shape
      centered_x = x - means
      inv_stdv = paddle.exp(-log_scales)
      plus_in = inv_stdv * (centered_x + 1.0 / 255.0)
      cdf_plus = approx_standard_normal_cdf(plus_in)
      min_in = inv_stdv * (centered_x - 1.0 / 255.0)
      cdf_min = approx_standard_normal_cdf(min_in)
      log_cdf_plus = paddle.log(cdf_plus.clip(min=1e-12))
      log_one_minus_cdf_min = paddle.log(
          (1.0 - cdf_min).clip(min=1e-12)
      )
      cdf_delta = cdf_plus - cdf_min
      log_probs = paddle.where(
          x < -0.999,
          log_cdf_plus,
          paddle.where(
              x > 0.999,
              log_one_minus_cdf_min,
              paddle.log(cdf_delta.clip(min=1e-12)),
          ),
      )
      assert log_probs.shape == x.shape
      return log_probs
  
file_path: PaddleHub/modules/image/text_to_image/disco_diffusion_cnclip_vitb16/reverse_diffusion/model/losses.py
imports: import numpy
  import paddle
  import paddle.nn.functional
label_desc: Use image node_id 3 for calling a global function with example usage: discretized_gaussian_log_likelihood(x) and returns: log_probs