% tinyrox says don't edit this manually, but it can't stop you!
\name{scheduler_add_noise}
\alias{scheduler_add_noise}
\title{Add noise to latents using DDIM scheduler}
\usage{
scheduler_add_noise(original_latents, noise, timestep, scheduler_obj)
}
\arguments{
\item{original_latents}{A torch tensor representing the original latents.}

\item{noise}{A torch tensor representing the noise to be added.}

\item{timestep}{An integer representing the current timestep in the diffusion
process.}

\item{scheduler_obj}{A list containing the DDIM scheduler parameters, including
alphas_cumprod and timesteps. The alphas_cumprod represents how much of the
original signal remains at each timestep of the diffusion process.}
}
\value{
A torch tensor containing the noised latents, which represents the
original latents with the appropriate amount of noise added for the given
timestep.
}
\description{
This function adds noise to the original latents according to the DDIM
scheduler's diffusion process. It computes the noisy latents based on the
original latents, noise, and the current timestep.
}
\details{
The noise is added according to the standard diffusion forward process formula:
noised_latents = sqrt(alpha_cumprod) * original_latents + sqrt(1-alpha_cumprod) * noise

Where alpha_cumprod is the cumulative product of (1-beta) values up to the
specified timestep, with beta being the noise schedule.
}
\examples{
if (torch::torch_is_installed()) {
  scheduler <- ddim_scheduler_create(num_inference_steps = 5)
  latents <- torch::torch_randn(c(1, 4, 8, 8))
  noised_latents <- scheduler_add_noise(
    original_latents = latents,
    noise = torch::torch_randn_like(latents),
    timestep = scheduler$timesteps[1],
    scheduler_obj = scheduler
  )
  noised_latents$shape
}

}
