class_docstr: Utilities for training and sampling diffusion models.
  
  Ported directly from here, and then adapted over time to further experimentation.
  https://github.com/hojonathanho/diffusion/blob/1e0dceb3b3495bbe19116a5e1b3596cd0706c543/diffusion_tf/diffusion_utils_2.py#L42
  
  :param betas: a 1-D numpy array of betas for each diffusion timestep,
                starting at T and going to 1.
  :param model_mean_type: a ModelMeanType determining what the model outputs.
  :param model_var_type: a ModelVarType determining how variance is output.
  :param loss_type: a LossType determining the loss function to use.
  :param rescale_timesteps: if True, pass floating point timesteps into the
                            model so that they are always scaled like in the
                            original paper (0 to 1000).
class_docstr_tok: ["Utilities","for","training","and","sampling","diffusion","models",".","Ported","directly","from","here",",","and","then","adapted","over","time","to","further","experimentation",".","https",":","\/\/github.com\/hojonathanho\/diffusion\/blob\/1e0dceb3b3495bbe19116a5e1b3596cd0706c543\/diffusion_tf\/diffusion_utils_2.py","#","L42",":","param","betas",":","a","1-D","numpy","array","of","betas","for","each","diffusion","timestep",",","starting","at","T","and","going","to","1.",":","param","model_mean_type",":","a","ModelMeanType","determining","what","the","model","outputs",".",":","param","model_var_type",":","a","ModelVarType","determining","how","variance","is","output",".",":","param","loss_type",":","a","LossType","determining","the","loss","function","to","use",".",":","param","rescale_timesteps",":","if","True",",","pass","floating","point","timesteps","into","the","model","so","that","they","are","always","scaled","like","in","the","original","paper","(","0","to","1000",")","."]
docstr: Generate samples from the model.
  
  :param model: the model module.
  :param shape: the shape of the samples, (N, C, H, W).
  :param noise: if specified, the noise from the encoder to sample.
                Should be of the same shape as `shape`.
  :param clip_denoised: if True, clip x_start predictions to [-1, 1].
  :param denoised_fn: if not None, a function which applies to the
      x_start prediction before it is used to sample.
  :param cond_fn: if not None, this is a gradient function that acts
                  similarly to the model.
  :param model_kwargs: if not None, a dict of extra keyword arguments to
      pass to the model. This can be used for conditioning.
  :param device: if specified, the device to create the samples on.
                 If not specified, use a model parameter's device.
  :param progress: if True, show a tqdm progress bar.
  :return: a non-differentiable batch of samples.
docstr_tok: ["Generate","samples","from","the","model",".",":","param","model",":","the","model","module",".",":","param","shape",":","the","shape","of","the","samples",",","(","N",",","C",",","H",",","W",")",".",":","param","noise",":","if","specified",",","the","noise","from","the","encoder","to","sample",".","Should","be","of","the","same","shape","as","`","shape","`",".",":","param","clip_denoised",":","if","True",",","clip","x_start","predictions","to","[","-1",",","1","]",".",":","param","denoised_fn",":","if","not","None",",","a","function","which","applies","to","the","x_start","prediction","before","it","is","used","to","sample",".",":","param","cond_fn",":","if","not","None",",","this","is","a","gradient","function","that","acts","similarly","to","the","model",".",":","param","model_kwargs",":","if","not","None",",","a","dict","of","extra","keyword","arguments","to","pass","to","the","model",".","This","can","be","used","for","conditioning",".",":","param","device",":","if","specified",",","the","device","to","create","the","samples","on",".","If","not","specified",",","use","a","model","parameter","'s","device",".",":","param","progress",":","if","True",",","show","a","tqdm","progress","bar",".",":","return",":","a","non-differentiable","batch","of","samples","."]
code: def p_sample_loop(
      self,
      model,
      shape,
      noise=None,
      clip_denoised=True,
      denoised_fn=None,
      cond_fn=None,
      model_kwargs=None,
      device=None,
      progress=False,
  ):
      """
      Generate samples from the model.
  
      :param model: the model module.
      :param shape: the shape of the samples, (N, C, H, W).
      :param noise: if specified, the noise from the encoder to sample.
                    Should be of the same shape as `shape`.
      :param clip_denoised: if True, clip x_start predictions to [-1, 1].
      :param denoised_fn: if not None, a function which applies to the
          x_start prediction before it is used to sample.
      :param cond_fn: if not None, this is a gradient function that acts
                      similarly to the model.
      :param model_kwargs: if not None, a dict of extra keyword arguments to
          pass to the model. This can be used for conditioning.
      :param device: if specified, the device to create the samples on.
                     If not specified, use a model parameter's device.
      :param progress: if True, show a tqdm progress bar.
      :return: a non-differentiable batch of samples.
      """
      final = None
      for sample in self.p_sample_loop_progressive(
          model,
          shape,
          noise=noise,
          clip_denoised=clip_denoised,
          denoised_fn=denoised_fn,
          cond_fn=cond_fn,
          model_kwargs=model_kwargs,
          device=device,
          progress=progress,
      ):
          final = sample
      return final["sample"]
  
imports: import enum
  import math
  import numpy
  import torch
  import torch
  from tqdm import tqdm
  from TTS.tts.layers.tortoise.dpm_solver import DPM_Solver, NoiseScheduleVP, model_wrapper
label_desc: Use image node_id 15 for calling the GaussianDiffusion obj's underlying member method code with example usage: obj.p_sample_loop(model, shape, noise, clip_denoised, denoised_fn, cond_fn, model_kwargs, device, progress) and returns: final