Implement the complete forward and backward diffusion processes used in Denoising Diffusion Probabilistic Models (DDPM).
The forward process gradually adds Gaussian noise to data according to a noise schedule (betas). Given clean data x_0, timestep t, and noise epsilon, compute the noisy sample x_t using the closed-form reparameterization.
The backward (reverse) process denoises the data by predicting and removing noise. Given x_t and a predicted noise from a model, compute x_{t-1} using the posterior distribution parameters.
Implement a function that:
The function should handle the special case when t=1 (final denoising step) where no additional noise is added.
Parameters: