code: def step(
      self,
      model_output: Union[paddle.Tensor, np.ndarray],
      timestep: int,
      sample: Union[paddle.Tensor, np.ndarray],
      eta: float = 0.0,
      use_clipped_model_output: bool = False,
      generator=None,
  ):
      # See formulas (12) and (16) of DDIM paper https://arxiv.org/pdf/2010.02502.pdf
      # Ideally, read DDIM paper in-detail understanding
  
      # Notation (<variable name> -> <name in paper>
      # - pred_noise_t -> e_theta(x_t, t)
      # - pred_original_sample -> f_theta(x_t, t) or x_0
      # - std_dev_t -> sigma_t
      # - eta -> η
      # - pred_sample_direction -> "direction pointingc to x_t"
      # - pred_prev_sample -> "x_t-1"
  
      # 1. get previous step value (=t-1)
      prev_timestep = (
          timestep
          - self.config.num_train_timesteps // self.num_inference_steps
      )
  
      # 2. compute alphas, betas
      alpha_prod_t = self.alphas_cumprod[timestep]
      alpha_prod_t_prev = (
          self.alphas_cumprod[prev_timestep]
          if prev_timestep >= 0
          else self.final_alpha_cumprod
      )
      beta_prod_t = 1 - alpha_prod_t
  
      # 3. compute predicted original sample from predicted noise also called
      # "predicted x_0" of formula (12) from https://arxiv.org/pdf/2010.02502.pdf
      pred_original_sample = (
          sample - beta_prod_t ** (0.5) * model_output
      ) / alpha_prod_t ** (0.5)
  
      # 4. Clip "predicted x_0"
      if self.config.clip_sample:
          pred_original_sample = self.clip(pred_original_sample, -1, 1)
  
      # 5. compute variance: "sigma_t(η)" -> see formula (16)
      # σ_t = sqrt((1 − α_t−1)/(1 − α_t)) * sqrt(1 − α_t/α_t−1)
      variance = self._get_variance(timestep, prev_timestep)
      std_dev_t = eta * variance ** (0.5)
  
      if use_clipped_model_output:
          # the model_output is always re-derived from the clipped x_0 in Glide
          model_output = (
              sample - alpha_prod_t ** (0.5) * pred_original_sample
          ) / beta_prod_t ** (0.5)
  
      # 6. compute "direction pointing to x_t" of formula (12) from https://arxiv.org/pdf/2010.02502.pdf
      pred_sample_direction = (
          1 - alpha_prod_t_prev - std_dev_t**2
      ) ** (0.5) * model_output
  
      # 7. compute x_t without "random noise" of formula (12) from https://arxiv.org/pdf/2010.02502.pdf
      prev_sample = (
          alpha_prod_t_prev ** (0.5) * pred_original_sample
          + pred_sample_direction
      )
  
      if eta > 0:
          noise = paddle.randn(model_output.shape)
          variance = (
              self._get_variance(timestep, prev_timestep) ** (0.5)
              * eta
              * noise
          )
  
          if not paddle.is_tensor(model_output):
              variance = variance.numpy()
  
          prev_sample = prev_sample + variance
  
      return {"prev_sample": prev_sample}
  
file_path: PaddleHub/modules/image/text_to_image/stable_diffusion_img2img/diffusers/schedulers/scheduling_ddim.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 DDIMScheduler obj's underlying member method code with example usage: obj.step(model_output, timestep, sample, eta, use_clipped_model_output, generator) and returns: dict