class_docstr: ## Base class for sampling algorithms
docstr: ## Get $\epsilon(x_t, c)$
  
  :param x: is $x_t$ of shape `[batch_size, channels, height, width]`
  :param t: is $t$ of shape `[batch_size]`
  :param c: is the conditional embeddings $c$ of shape `[batch_size, emb_size]`
  :param uncond_scale: is the unconditional guidance scale $s$. This is used for
      $\epsilon_  heta(x_t, c) = s\epsilon_       ext{cond}(x_t, c) + (s - 1)\epsilon_    ext{cond}(x_t, c_u)$
  :param uncond_cond: is the conditional embedding for empty prompt $c_u$
code: def get_eps(
      self,
      x: torch.Tensor,
      t: torch.Tensor,
      c: torch.Tensor,
      *,
      uncond_scale: float,
      uncond_cond: Optional[torch.Tensor],
  ):
      """
      ## Get $\epsilon(x_t, c)$
  
      :param x: is $x_t$ of shape `[batch_size, channels, height, width]`
      :param t: is $t$ of shape `[batch_size]`
      :param c: is the conditional embeddings $c$ of shape `[batch_size, emb_size]`
      :param uncond_scale: is the unconditional guidance scale $s$. This is used for
          $\epsilon_\theta(x_t, c) = s\epsilon_\text{cond}(x_t, c) + (s - 1)\epsilon_\text{cond}(x_t, c_u)$
      :param uncond_cond: is the conditional embedding for empty prompt $c_u$
      """
      # When the scale $s = 1$
      # $$\epsilon_\theta(x_t, c) = \epsilon_\text{cond}(x_t, c)$$
      if uncond_cond is None or uncond_scale == 1.0:
          return self.model(x, t, c)
  
      # Duplicate $x_t$ and $t$
      x_in = torch.cat([x] * 2)
      t_in = torch.cat([t] * 2)
      # Concatenated $c$ and $c_u$
      c_in = torch.cat([uncond_cond, c])
      # Get $\epsilon_\text{cond}(x_t, c)$ and $\epsilon_\text{cond}(x_t, c_u)$
      e_t_uncond, e_t_cond = self.model(x_in, t_in, c_in).chunk(2)
      # Calculate
      # $$\epsilon_\theta(x_t, c) = s\epsilon_\text{cond}(x_t, c) + (s - 1)\epsilon_\text{cond}(x_t, c_u)$$
      e_t = e_t_uncond + uncond_scale * (e_t_cond - e_t_uncond)
  
      #
      return e_t
  
file_path: annotated_deep_learning_paper_implementations/labml_nn/diffusion/stable_diffusion/sampler/__init__.py
imports: from typing import Optional, List
  import torch
  from labml_nn.diffusion.stable_diffusion.latent_diffusion import LatentDiffusion
label_desc: Use image node_id 2 for calling the DiffusionSampler obj's underlying member method code with example usage: obj.get_eps(x, t, c) and returns: e_t, self