docstr: Step function propagating the sample with the Runge-Kutta method. RK takes 4 forward passes to approximate the
  solution to the differential equation.
docstr_tok: ["Step","function","propagating","the","sample","with","the","Runge-Kutta","method",".","RK","takes","4","forward","passes","to","approximate","the","solution","to","the","differential","equation","."]
code: def step_prk(
      self,
      model_output: Union[paddle.Tensor, np.ndarray],
      timestep: int,
      sample: Union[paddle.Tensor, np.ndarray],
  ):
      """
      Step function propagating the sample with the Runge-Kutta method. RK takes 4 forward passes to approximate the
      solution to the differential equation.
      """
      diff_to_prev = (
          0
          if self.counter % 2
          else self.config.num_train_timesteps
          // self.num_inference_steps
          // 2
      )
      prev_timestep = max(
          timestep - diff_to_prev, self.prk_timesteps[-1]
      )
      timestep = self.prk_timesteps[self.counter // 4 * 4]
  
      if self.counter % 4 == 0:
          self.cur_model_output += 1 / 6 * model_output
          self.ets.append(model_output)
          self.cur_sample = sample
      elif (self.counter - 1) % 4 == 0:
          self.cur_model_output += 1 / 3 * model_output
      elif (self.counter - 2) % 4 == 0:
          self.cur_model_output += 1 / 3 * model_output
      elif (self.counter - 3) % 4 == 0:
          model_output = self.cur_model_output + 1 / 6 * model_output
          self.cur_model_output = 0
  
      # cur_sample should not be `None`
      cur_sample = (
          self.cur_sample if self.cur_sample is not None else sample
      )
  
      prev_sample = self._get_prev_sample(
          cur_sample, timestep, prev_timestep, model_output
      )
      self.counter += 1
  
      return {"prev_sample": prev_sample}
  
file_path: PaddleHub/modules/image/text_to_image/stable_diffusion/diffusers/schedulers/scheduling_pndm.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 PNDMScheduler obj's underlying member method code with example usage: obj.step_prk(model_output, timestep, sample) and returns: dict