code: def step(
      self,
      model_output: Union[paddle.Tensor, np.ndarray],
      timestep: int,
      sample: Union[paddle.Tensor, np.ndarray],
      predict_epsilon=True,
      generator=None,
  ):
      t = timestep
  
      if model_output.shape[1] == sample.shape[
          1
      ] * 2 and self.variance_type in ["learned", "learned_range"]:
          model_output, predicted_variance = paddle.split(
              model_output, sample.shape[1], axis=1
          )
      else:
          predicted_variance = None
  
      # 1. compute alphas, betas
      alpha_prod_t = self.alphas_cumprod[t]
      alpha_prod_t_prev = (
          self.alphas_cumprod[t - 1] if t > 0 else self.one
      )
      beta_prod_t = 1 - alpha_prod_t
      beta_prod_t_prev = 1 - alpha_prod_t_prev
  
      # 2. compute predicted original sample from predicted noise also called
      # "predicted x_0" of formula (15) from https://arxiv.org/pdf/2006.11239.pdf
      if predict_epsilon:
          pred_original_sample = (
              sample - beta_prod_t ** (0.5) * model_output
          ) / alpha_prod_t ** (0.5)
      else:
          pred_original_sample = model_output
  
      # 3. Clip "predicted x_0"
      if self.config.clip_sample:
          pred_original_sample = self.clip(pred_original_sample, -1, 1)
  
      # 4. Compute coefficients for pred_original_sample x_0 and current sample x_t
      # See formula (7) from https://arxiv.org/pdf/2006.11239.pdf
      pred_original_sample_coeff = (
          alpha_prod_t_prev ** (0.5) * self.betas[t]
      ) / beta_prod_t
      current_sample_coeff = (
          self.alphas[t] ** (0.5) * beta_prod_t_prev / beta_prod_t
      )
  
      # 5. Compute predicted previous sample µ_t
      # See formula (7) from https://arxiv.org/pdf/2006.11239.pdf
      pred_prev_sample = (
          pred_original_sample_coeff * pred_original_sample
          + current_sample_coeff * sample
      )
  
      # 6. Add noise
      variance = 0
      if t > 0:
          noise = self.randn_like(model_output)
          variance = (
              self._get_variance(
                  t, predicted_variance=predicted_variance
              )
              ** 0.5
          ) * noise
  
      pred_prev_sample = pred_prev_sample + variance
  
      return {"prev_sample": pred_prev_sample}
  
file_path: PaddleHub/modules/image/text_to_image/stable_diffusion_img2img/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 4 for calling the DDPMScheduler obj's underlying member method code with example usage: obj.step(model_output, timestep, sample, predict_epsilon, generator) and returns: dict