class_docstr: `PNDMScheduler` uses pseudo numerical methods for diffusion models such as the Runge-Kutta and linear multi-step
  method.
  
  This model inherits from [`SchedulerMixin`] and [`ConfigMixin`]. Check the superclass documentation for the generic
  methods the library implements for all schedulers such as loading and saving.
  
  Args:
      num_train_timesteps (`int`, defaults to 1000):
          The number of diffusion steps to train the model.
      beta_start (`float`, defaults to 0.0001):
          The starting `beta` value of inference.
      beta_end (`float`, defaults to 0.02):
          The final `beta` value.
      beta_schedule (`str`, defaults to `"linear"`):
          The beta schedule, a mapping from a beta range to a sequence of betas for stepping the model. Choose from
          `linear`, `scaled_linear`, or `squaredcos_cap_v2`.
      trained_betas (`np.ndarray`, *optional*):
          Pass an array of betas directly to the constructor to bypass `beta_start` and `beta_end`.
      skip_prk_steps (`bool`, defaults to `False`):
          Allows the scheduler to skip the Runge-Kutta steps defined in the original paper as being required before
          PLMS steps.
      set_alpha_to_one (`bool`, defaults to `False`):
          Each diffusion step uses the alphas product value at that step and at the previous one. For the final step
          there is no previous alpha. When this option is `True` the previous alpha product is fixed to `1`,
          otherwise it uses the alpha value at step 0.
      prediction_type (`str`, defaults to `epsilon`, *optional*):
          Prediction type of the scheduler function; can be `epsilon` (predicts the noise of the diffusion process)
          or `v_prediction` (see section 2.4 of [Imagen Video](https://imagen.research.google/video/paper.pdf)
          paper).
      timestep_spacing (`str`, defaults to `"leading"`):
          The way the timesteps should be scaled. Refer to Table 2 of the [Common Diffusion Noise Schedules and
          Sample Steps are Flawed](https://huggingface.co/papers/2305.08891) for more information.
      steps_offset (`int`, defaults to 0):
          An offset added to the inference steps. You can use a combination of `offset=1` and
          `set_alpha_to_one=False` to make the last step use step 0 for the previous alpha product like in Stable
          Diffusion.
class_docstr_tok: ["`","PNDMScheduler","`","uses","pseudo","numerical","methods","for","diffusion","models","such","as","the","Runge-Kutta","and","linear","multi-step","method",".","This","model","inherits","from","[","`","SchedulerMixin","`","]","and","[","`","ConfigMixin","`","]",".","Check","the","superclass","documentation","for","the","generic","methods","the","library","implements","for","all","schedulers","such","as","loading","and","saving",".","Args",":","num_train_timesteps","(","`","int","`",",","defaults","to","1000",")",":","The","number","of","diffusion","steps","to","train","the","model",".","beta_start","(","`","float","`",",","defaults","to","0.0001",")",":","The","starting","`","beta","`","value","of","inference",".","beta_end","(","`","float","`",",","defaults","to","0.02",")",":","The","final","`","beta","`","value",".","beta_schedule","(","`","str","`",",","defaults","to","`","``","linear","''","`",")",":","The","beta","schedule",",","a","mapping","from","a","beta","range","to","a","sequence","of","betas","for","stepping","the","model",".","Choose","from","`","linear","`",",","`","scaled_linear","`",",","or","`","squaredcos_cap_v2","`",".","trained_betas","(","`","np.ndarray","`",",","*","optional","*",")",":","Pass","an","array","of","betas","directly","to","the","constructor","to","bypass","`","beta_start","`","and","`","beta_end","`",".","skip_prk_steps","(","`","bool","`",",","defaults","to","`","False","`",")",":","Allows","the","scheduler","to","skip","the","Runge-Kutta","steps","defined","in","the","original","paper","as","being","required","before","PLMS","steps",".","set_alpha_to_one","(","`","bool","`",",","defaults","to","`","False","`",")",":","Each","diffusion","step","uses","the","alphas","product","value","at","that","step","and","at","the","previous","one",".","For","the","final","step","there","is","no","previous","alpha",".","When","this","option","is","`","True","`","the","previous","alpha","product","is","fixed","to","`","1","`",",","otherwise","it","uses","the","alpha","value","at","step","0.","prediction_type","(","`","str","`",",","defaults","to","`","epsilon","`",",","*","optional","*",")",":","Prediction","type","of","the","scheduler","function",";","can","be","`","epsilon","`","(","predicts","the","noise","of","the","diffusion","process",")","or","`","v_prediction","`","(","see","section","2.4","of","[","Imagen","Video","]","(","https",":","\/\/imagen.research.google\/video\/paper.pdf",")","paper",")",".","timestep_spacing","(","`","str","`",",","defaults","to","`","``","leading","''","`",")",":","The","way","the","timesteps","should","be","scaled",".","Refer","to","Table","2","of","the","[","Common","Diffusion","Noise","Schedules","and","Sample","Steps","are","Flawed","]","(","https",":","\/\/huggingface.co\/papers\/2305.08891",")","for","more","information",".","steps_offset","(","`","int","`",",","defaults","to","0",")",":","An","offset","added","to","the","inference","steps",".","You","can","use","a","combination","of","`","offset=1","`","and","`","set_alpha_to_one=False","`","to","make","the","last","step","use","step","0","for","the","previous","alpha","product","like","in","Stable","Diffusion","."]
docstr: Predict the sample from the previous timestep by reversing the SDE. This function propagates the sample with
  the Runge-Kutta method. It performs four forward passes to approximate the solution to the differential
  equation.
  
  Args:
      model_output (`torch.FloatTensor`):
          The direct output from learned diffusion model.
      timestep (`int`):
          The current discrete timestep in the diffusion chain.
      sample (`torch.FloatTensor`):
          A current instance of a sample created by the diffusion process.
      return_dict (`bool`):
          Whether or not to return a [`~schedulers.scheduling_utils.SchedulerOutput`] or tuple.
  
  Returns:
      [`~schedulers.scheduling_utils.SchedulerOutput`] or `tuple`:
          If return_dict is `True`, [`~schedulers.scheduling_utils.SchedulerOutput`] is returned, otherwise a
          tuple is returned where the first element is the sample tensor.
docstr_tok: ["Predict","the","sample","from","the","previous","timestep","by","reversing","the","SDE",".","This","function","propagates","the","sample","with","the","Runge-Kutta","method",".","It","performs","four","forward","passes","to","approximate","the","solution","to","the","differential","equation",".","Args",":","model_output","(","`","torch.FloatTensor","`",")",":","The","direct","output","from","learned","diffusion","model",".","timestep","(","`","int","`",")",":","The","current","discrete","timestep","in","the","diffusion","chain",".","sample","(","`","torch.FloatTensor","`",")",":","A","current","instance","of","a","sample","created","by","the","diffusion","process",".","return_dict","(","`","bool","`",")",":","Whether","or","not","to","return","a","[","`","~schedulers.scheduling_utils.SchedulerOutput","`","]","or","tuple",".","Returns",":","[","`","~schedulers.scheduling_utils.SchedulerOutput","`","]","or","`","tuple","`",":","If","return_dict","is","`","True","`",",","[","`","~schedulers.scheduling_utils.SchedulerOutput","`","]","is","returned",",","otherwise","a","tuple","is","returned","where","the","first","element","is","the","sample","tensor","."]
code: def step_prk(
      self,
      model_output: torch.FloatTensor,
      timestep: int,
      sample: torch.FloatTensor,
      return_dict: bool = True,
  ) -> Union[SchedulerOutput, Tuple]:
      """
      Predict the sample from the previous timestep by reversing the SDE. This function propagates the sample with
      the Runge-Kutta method. It performs four forward passes to approximate the solution to the differential
      equation.
  
      Args:
          model_output (`torch.FloatTensor`):
              The direct output from learned diffusion model.
          timestep (`int`):
              The current discrete timestep in the diffusion chain.
          sample (`torch.FloatTensor`):
              A current instance of a sample created by the diffusion process.
          return_dict (`bool`):
              Whether or not to return a [`~schedulers.scheduling_utils.SchedulerOutput`] or tuple.
  
      Returns:
          [`~schedulers.scheduling_utils.SchedulerOutput`] or `tuple`:
              If return_dict is `True`, [`~schedulers.scheduling_utils.SchedulerOutput`] is returned, otherwise a
              tuple is returned where the first element is the sample tensor.
  
      """
      if self.num_inference_steps is None:
          raise ValueError(
              "Number of inference steps is 'None', you need to run 'set_timesteps' after creating the scheduler"
          )
  
      diff_to_prev = (
          0
          if self.counter % 2
          else self.config.num_train_timesteps
          // self.num_inference_steps
          // 2
      )
      prev_timestep = timestep - diff_to_prev
      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
  
      if not return_dict:
          return (prev_sample,)
  
      return SchedulerOutput(prev_sample=prev_sample)
  
file_path: llmga/llmga/diffusers/src/diffusers/schedulers/scheduling_pndm.py
imports: import math
  from typing import List, Optional, Tuple, Union
  import numpy
  import torch
  from ..configuration_utils import ConfigMixin, register_to_config
  from .scheduling_utils import KarrasDiffusionSchedulers, SchedulerMixin, SchedulerOutput
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, return_dict) and returns: SchedulerOutput, prev_sample