class_docstr: ## Denoise Diffusion
class_docstr_tok: ["#","#","Denoise","Diffusion"]
docstr: #### Get $q(x_t|x_0)$ distribution
  
  egin{align}
  q(x_t|x_0) &= \mathcal{N} \Big(x_t; \sqrt{arlpha_t} x_0, (1-arlpha_t) \mathbf{I} \Big)
  \end{align}
docstr_tok: ["#","#","#","#","Get","$","q","(","x_t|x_0",")","$","distribution","\begin","{","align","}","q","(","x_t|x_0",")","&","=","\\mathcal","{","N","}","\\Big","(","x_t",";","\\sqrt","{","\bar\u0007lpha_t","}","x_0",",","(","1-\bar\u0007lpha_t",")","\\mathbf","{","I","}","\\Big",")","\\end","{","align","}"]
code: def q_xt_x0(
      self, x0: torch.Tensor, t: torch.Tensor
  ) -> Tuple[torch.Tensor, torch.Tensor]:
      """
      #### Get $q(x_t|x_0)$ distribution
  
      \begin{align}
      q(x_t|x_0) &= \mathcal{N} \Big(x_t; \sqrt{\bar\alpha_t} x_0, (1-\bar\alpha_t) \mathbf{I} \Big)
      \end{align}
      """
  
      # [gather](utils.html) $\alpha_t$ and compute $\sqrt{\bar\alpha_t} x_0$
      mean = gather(self.alpha_bar, t) ** 0.5 * x0
      # $(1-\bar\alpha_t) \mathbf{I}$
      var = 1 - gather(self.alpha_bar, t)
      #
      return mean, var
  
file_path: annotated_deep_learning_paper_implementations/labml_nn/diffusion/ddpm/__init__.py
imports: from typing import Tuple, Optional
  import torch
  import torch.nn.functional
  import torch.utils.data
  from torch import nn
  from labml_nn.diffusion.ddpm.utils import gather
label_desc: Use image node_id 2 for calling the DenoiseDiffusion obj's underlying member method code with example usage: obj.q_xt_x0(x0, t) and returns: mean,  var