class_docstr: Noise schedule for diffusion.
  
  Args:
      beta_t0 (float): Variance of the first diffusion step.
      beta_t1 (float): Variance of the last diffusion step.
      beta_exp (float): Power schedule exponent
      num_steps (int): Number of diffusion step.
      variance (str): choice of the sigma value for the denoising eq. Choices: "beta" or "beta_tilde"
      clip (float): clipping value for the denoising steps
      rescale (float): rescaling value to avoid vanishing signals unused by default (i.e 1)
      repartition (str): shape of the schedule only power schedule is supported
      sample_processor (SampleProcessor): Module that normalize data to match better the gaussian distribution
      noise_scale (float): Scaling factor for the noise
class_docstr_tok: ["Noise","schedule","for","diffusion",".","Args",":","beta_t0","(","float",")",":","Variance","of","the","first","diffusion","step",".","beta_t1","(","float",")",":","Variance","of","the","last","diffusion","step",".","beta_exp","(","float",")",":","Power","schedule","exponent","num_steps","(","int",")",":","Number","of","diffusion","step",".","variance","(","str",")",":","choice","of","the","sigma","value","for","the","denoising","eq",".","Choices",":","``","beta","''","or","``","beta_tilde","''","clip","(","float",")",":","clipping","value","for","the","denoising","steps","rescale","(","float",")",":","rescaling","value","to","avoid","vanishing","signals","unused","by","default","(","i.e","1",")","repartition","(","str",")",":","shape","of","the","schedule","only","power","schedule","is","supported","sample_processor","(","SampleProcessor",")",":","Module","that","normalize","data","to","match","better","the","gaussian","distribution","noise_scale","(","float",")",":","Scaling","factor","for","the","noise"]
docstr: Full ddpm reverse process.
  
  Args:
      model (nn.Module): Diffusion model.
      initial (tensor): Initial Noise.
      condition (tensor): Input conditionning Tensor (e.g. encodec compressed representation).
      return_list (bool): Whether to return the whole process or only the sampled point.
docstr_tok: ["Full","ddpm","reverse","process",".","Args",":","model","(","nn.Module",")",":","Diffusion","model",".","initial","(","tensor",")",":","Initial","Noise",".","condition","(","tensor",")",":","Input","conditionning","Tensor","(","e.g",".","encodec","compressed","representation",")",".","return_list","(","bool",")",":","Whether","to","return","the","whole","process","or","only","the","sampled","point","."]
code: def generate(
      self,
      model: torch.nn.Module,
      initial: tp.Optional[torch.Tensor] = None,
      condition: tp.Optional[torch.Tensor] = None,
      return_list: bool = False,
  ):
      """Full ddpm reverse process.
  
      Args:
          model (nn.Module): Diffusion model.
          initial (tensor): Initial Noise.
          condition (tensor): Input conditionning Tensor (e.g. encodec compressed representation).
          return_list (bool): Whether to return the whole process or only the sampled point.
      """
      alpha_bar = self.get_alpha_bar(step=self.num_steps - 1)
      current = initial
      iterates = [initial]
      for step in range(self.num_steps)[::-1]:
          with torch.no_grad():
              estimate = model(
                  current, step, condition=condition
              ).sample
          alpha = 1 - self.betas[step]
          previous = (
              current - (1 - alpha) / (1 - alpha_bar).sqrt() * estimate
          ) / alpha.sqrt()
          previous_alpha_bar = self.get_alpha_bar(step=step - 1)
          if step == 0:
              sigma2 = 0
          elif self.variance == "beta":
              sigma2 = 1 - alpha
          elif self.variance == "beta_tilde":
              sigma2 = (
                  (1 - previous_alpha_bar)
                  / (1 - alpha_bar)
                  * (1 - alpha)
              )
          elif self.variance == "none":
              sigma2 = 0
          else:
              raise ValueError(f"Invalid variance type {self.variance}")
  
          if sigma2 > 0:
              previous += (
                  sigma2**0.5
                  * torch.randn_like(previous)
                  * self.noise_scale
              )
          if self.clip:
              previous = previous.clamp(-self.clip, self.clip)
          current = previous
          alpha_bar = previous_alpha_bar
          if step == 0:
              previous *= self.rescale
          if return_list:
              iterates.append(previous.cpu())
  
      if return_list:
          return iterates
      else:
          return self.sample_processor.return_sample(previous)
  
imports: from collections import namedtuple
  import random
  import typing
  import julius
  import torch
label_desc: Use image node_id 6 for calling the NoiseSchedule obj's underlying member method code with example usage: obj.generate(model, initial, condition, return_list) and returns: iterates, self