code: def _get_variance(
      self, t, predicted_variance=None, variance_type=None
  ):
      alpha_prod_t = self.alphas_cumprod[t]
      alpha_prod_t_prev = (
          self.alphas_cumprod[t - 1] if t > 0 else self.one
      )
  
      # For t > 0, compute predicted variance βt (see formula (6) and (7) from https://arxiv.org/pdf/2006.11239.pdf)
      # and sample from it to get previous sample
      # x_{t-1} ~ N(pred_prev_sample, variance) == add variance to pred_sample
      variance = (
          (1 - alpha_prod_t_prev) / (1 - alpha_prod_t) * self.betas[t]
      )
  
      if variance_type is None:
          variance_type = self.config.variance_type
  
      # hacks - were probs added for training stability
      if variance_type == "fixed_small":
          variance = self.clip(variance, min_value=1e-20)
      # for rl-diffuser https://arxiv.org/abs/2205.09991
      elif variance_type == "fixed_small_log":
          variance = self.log(self.clip(variance, min_value=1e-20))
      elif variance_type == "fixed_large":
          variance = self.betas[t]
      elif variance_type == "fixed_large_log":
          # Glide max_log
          variance = self.log(self.betas[t])
      elif variance_type == "learned":
          return predicted_variance
      elif variance_type == "learned_range":
          min_log = variance
          max_log = self.betas[t]
          frac = (predicted_variance + 1) / 2
          variance = frac * max_log + (1 - frac) * min_log
  
      return variance
  
file_path: PaddleHub/modules/image/text_to_image/stable_diffusion_inpainting/diffusers/schedulers/scheduling_ddpm.py
imports: import math
  from typing import Union
  import numpy
  import paddle
  from ..configuration_utils import ConfigMixin
  from ..configuration_utils import register_to_config
  from .scheduling_utils import SchedulerMixin
label_desc: Use image node_id 3 for calling the DDPMScheduler obj's underlying member method code with example usage: obj._get_variance(t, predicted_variance, variance_type) and returns: variance, predicted_variance