class_docstr: Euler scheduler.
  
  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` or `scaled_linear`.
      trained_betas (`np.ndarray`, *optional*):
          Pass an array of betas directly to the constructor to bypass `beta_start` and `beta_end`.
      prediction_type (`str`, defaults to `epsilon`, *optional*):
          Prediction type of the scheduler function; can be `epsilon` (predicts the noise of the diffusion process),
          `sample` (directly predicts the noisy sample`) or `v_prediction` (see section 2.4 of [Imagen
          Video](https://imagen.research.google/video/paper.pdf) paper).
      interpolation_type(`str`, defaults to `"linear"`, *optional*):
          The interpolation type to compute intermediate sigmas for the scheduler denoising steps. Should be on of
          `"linear"` or `"log_linear"`.
      use_karras_sigmas (`bool`, *optional*, defaults to `False`):
          Whether to use Karras sigmas for step sizes in the noise schedule during the sampling process. If `True`,
          the sigmas are determined according to a sequence of noise levels {σi}.
      timestep_spacing (`str`, defaults to `"linspace"`):
          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: ["Euler","scheduler",".","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","`","or","`","scaled_linear","`",".","trained_betas","(","`","np.ndarray","`",",","*","optional","*",")",":","Pass","an","array","of","betas","directly","to","the","constructor","to","bypass","`","beta_start","`","and","`","beta_end","`",".","prediction_type","(","`","str","`",",","defaults","to","`","epsilon","`",",","*","optional","*",")",":","Prediction","type","of","the","scheduler","function",";","can","be","`","epsilon","`","(","predicts","the","noise","of","the","diffusion","process",")",",","`","sample","`","(","directly","predicts","the","noisy","sample","`",")","or","`","v_prediction","`","(","see","section","2.4","of","[","Imagen","Video","]","(","https",":","\/\/imagen.research.google\/video\/paper.pdf",")","paper",")",".","interpolation_type","(","`","str","`",",","defaults","to","`","``","linear","''","`",",","*","optional","*",")",":","The","interpolation","type","to","compute","intermediate","sigmas","for","the","scheduler","denoising","steps",".","Should","be","on","of","`","``","linear","''","`","or","`","``","log_linear","''","`",".","use_karras_sigmas","(","`","bool","`",",","*","optional","*",",","defaults","to","`","False","`",")",":","Whether","to","use","Karras","sigmas","for","step","sizes","in","the","noise","schedule","during","the","sampling","process",".","If","`","True","`",",","the","sigmas","are","determined","according","to","a","sequence","of","noise","levels","{","\u03c3i","}",".","timestep_spacing","(","`","str","`",",","defaults","to","`","``","linspace","''","`",")",":","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 diffusion
  process from the learned model outputs (most often the predicted noise).
  
  Args:
      model_output (`torch.FloatTensor`):
          The direct output from learned diffusion model.
      timestep (`float`):
          The current discrete timestep in the diffusion chain.
      sample (`torch.FloatTensor`):
          A current instance of a sample created by the diffusion process.
      s_churn (`float`):
      s_tmin  (`float`):
      s_tmax  (`float`):
      s_noise (`float`, defaults to 1.0):
          Scaling factor for noise added to the sample.
      generator (`torch.Generator`, *optional*):
          A random number generator.
      return_dict (`bool`):
          Whether or not to return a [`~schedulers.scheduling_euler_discrete.EulerDiscreteSchedulerOutput`] or
          tuple.
  
  Returns:
      [`~schedulers.scheduling_euler_discrete.EulerDiscreteSchedulerOutput`] or `tuple`:
          If return_dict is `True`, [`~schedulers.scheduling_euler_discrete.EulerDiscreteSchedulerOutput`] 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","diffusion","process","from","the","learned","model","outputs","(","most","often","the","predicted","noise",")",".","Args",":","model_output","(","`","torch.FloatTensor","`",")",":","The","direct","output","from","learned","diffusion","model",".","timestep","(","`","float","`",")",":","The","current","discrete","timestep","in","the","diffusion","chain",".","sample","(","`","torch.FloatTensor","`",")",":","A","current","instance","of","a","sample","created","by","the","diffusion","process",".","s_churn","(","`","float","`",")",":","s_tmin","(","`","float","`",")",":","s_tmax","(","`","float","`",")",":","s_noise","(","`","float","`",",","defaults","to","1.0",")",":","Scaling","factor","for","noise","added","to","the","sample",".","generator","(","`","torch.Generator","`",",","*","optional","*",")",":","A","random","number","generator",".","return_dict","(","`","bool","`",")",":","Whether","or","not","to","return","a","[","`","~schedulers.scheduling_euler_discrete.EulerDiscreteSchedulerOutput","`","]","or","tuple",".","Returns",":","[","`","~schedulers.scheduling_euler_discrete.EulerDiscreteSchedulerOutput","`","]","or","`","tuple","`",":","If","return_dict","is","`","True","`",",","[","`","~schedulers.scheduling_euler_discrete.EulerDiscreteSchedulerOutput","`","]","is","returned",",","otherwise","a","tuple","is","returned","where","the","first","element","is","the","sample","tensor","."]
code: def step(
      self,
      model_output: torch.FloatTensor,
      timestep: Union[float, torch.FloatTensor],
      sample: torch.FloatTensor,
      s_churn: float = 0.0,
      s_tmin: float = 0.0,
      s_tmax: float = float("inf"),
      s_noise: float = 1.0,
      generator: Optional[torch.Generator] = None,
      return_dict: bool = True,
  ) -> Union[EulerDiscreteSchedulerOutput, Tuple]:
      """
      Predict the sample from the previous timestep by reversing the SDE. This function propagates the diffusion
      process from the learned model outputs (most often the predicted noise).
  
      Args:
          model_output (`torch.FloatTensor`):
              The direct output from learned diffusion model.
          timestep (`float`):
              The current discrete timestep in the diffusion chain.
          sample (`torch.FloatTensor`):
              A current instance of a sample created by the diffusion process.
          s_churn (`float`):
          s_tmin  (`float`):
          s_tmax  (`float`):
          s_noise (`float`, defaults to 1.0):
              Scaling factor for noise added to the sample.
          generator (`torch.Generator`, *optional*):
              A random number generator.
          return_dict (`bool`):
              Whether or not to return a [`~schedulers.scheduling_euler_discrete.EulerDiscreteSchedulerOutput`] or
              tuple.
  
      Returns:
          [`~schedulers.scheduling_euler_discrete.EulerDiscreteSchedulerOutput`] or `tuple`:
              If return_dict is `True`, [`~schedulers.scheduling_euler_discrete.EulerDiscreteSchedulerOutput`] is
              returned, otherwise a tuple is returned where the first element is the sample tensor.
      """
  
      if (
          isinstance(timestep, int)
          or isinstance(timestep, torch.IntTensor)
          or isinstance(timestep, torch.LongTensor)
      ):
          raise ValueError(
              (
                  "Passing integer indices (e.g. from `enumerate(timesteps)`) as timesteps to"
                  " `EulerDiscreteScheduler.step()` is not supported. Make sure to pass"
                  " one of the `scheduler.timesteps` as a timestep."
              ),
          )
  
      if not self.is_scale_input_called:
          logger.warning(
              "The `scale_model_input` function should be called before `step` to ensure correct denoising. "
              "See `StableDiffusionPipeline` for a usage example."
          )
  
      if self.step_index is None:
          self._init_step_index(timestep)
  
      sigma = self.sigmas[self.step_index]
  
      gamma = (
          min(s_churn / (len(self.sigmas) - 1), 2**0.5 - 1)
          if s_tmin <= sigma <= s_tmax
          else 0.0
      )
  
      noise = randn_tensor(
          model_output.shape,
          dtype=model_output.dtype,
          device=model_output.device,
          generator=generator,
      )
  
      eps = noise * s_noise
      sigma_hat = sigma * (gamma + 1)
  
      if gamma > 0:
          sample = sample + eps * (sigma_hat**2 - sigma**2) ** 0.5
  
      # 1. compute predicted original sample (x_0) from sigma-scaled predicted noise
      # NOTE: "original_sample" should not be an expected prediction_type but is left in for
      # backwards compatibility
      if (
          self.config.prediction_type == "original_sample"
          or self.config.prediction_type == "sample"
      ):
          pred_original_sample = model_output
      elif self.config.prediction_type == "epsilon":
          pred_original_sample = sample - sigma_hat * model_output
      elif self.config.prediction_type == "v_prediction":
          # * c_out + input * c_skip
          pred_original_sample = model_output * (
              -sigma / (sigma**2 + 1) ** 0.5
          ) + (sample / (sigma**2 + 1))
      else:
          raise ValueError(
              f"prediction_type given as {self.config.prediction_type} must be one of `epsilon`, or `v_prediction`"
          )
  
      # 2. Convert to an ODE derivative
      derivative = (sample - pred_original_sample) / sigma_hat
  
      dt = self.sigmas[self.step_index + 1] - sigma_hat
  
      prev_sample = sample + derivative * dt
  
      # upon completion increase step index by one
      self._step_index += 1
  
      if not return_dict:
          return (prev_sample,)
  
      return EulerDiscreteSchedulerOutput(
          prev_sample=prev_sample,
          pred_original_sample=pred_original_sample,
      )
  
imports: import math
  from dataclasses import dataclass
  from typing import List, Optional, Tuple, Union
  import numpy
  import torch
  from ..configuration_utils import ConfigMixin, register_to_config
  from ..utils import BaseOutput, logging
  from ..utils.torch_utils import randn_tensor
  from .scheduling_utils import KarrasDiffusionSchedulers, SchedulerMixin
label_desc: Use image node_id 9 for calling the EulerDiscreteScheduler obj's underlying member method code with example usage: obj.step(model_output, timestep, sample, s_churn, s_tmin, s_tmax, s_noise, generator, return_dict) and returns: EulerDiscreteSchedulerOutput, prev_sample