class_docstr: ## Sampler class
class_docstr_tok: ["#","#","Sampler","class"]
docstr: #### Sample an image using $    extcolor{lightgreen}{p_ heta}(x_{t-1}|x_t)$
  
  * `xt` is $x_t$
  * `n_steps` is $t$
docstr_tok: ["#","#","#","#","Sample","an","image","using","$","extcolor","{","lightgreen","}","{","p_","heta","}","(","x_","{","t-1","}","|x_t",")","$","*","`","xt","`","is","$","x_t","$","*","`","n_steps","`","is","$","t","$"]
code: def _sample_x0(self, xt: torch.Tensor, n_steps: int):
      """
      #### Sample an image using $\textcolor{lightgreen}{p_\theta}(x_{t-1}|x_t)$
  
      * `xt` is $x_t$
      * `n_steps` is $t$
      """
  
      # Number of sampels
      n_samples = xt.shape[0]
      # Iterate until $t$ steps
      for t_ in monit.iterate("Denoise", n_steps):
          t = n_steps - t_ - 1
          # Sample from $\textcolor{lightgreen}{p_\theta}(x_{t-1}|x_t)$
          xt = self.diffusion.p_sample(
              xt, xt.new_full((n_samples,), t, dtype=torch.long)
          )
  
      # Return $x_0$
      return xt
  
file_path: annotated_deep_learning_paper_implementations/labml_nn/diffusion/ddpm/evaluate.py
imports: import numpy
  import torch
  from matplotlib import pyplot
  from torchvision.transforms.functional import to_pil_image, resize
  from labml import experiment, monit
  from labml_nn.diffusion.ddpm import DenoiseDiffusion, gather
  from labml_nn.diffusion.ddpm.experiment import Configs
label_desc: Use image node_id 7 for calling the Sampler obj's underlying member method code with example usage: obj._sample_x0(xt, n_steps) and returns: xt