class_docstr: ## Latent diffusion model
  
  This contains following components:
  
  * [AutoEncoder](model/autoencoder.html)
  * [U-Net](model/unet.html) with [attention](model/unet_attention.html)
  * [CLIP embeddings generator](model/clip_embedder.html)
class_docstr_tok: ["#","#","Latent","diffusion","model","This","contains","following","components",":","*","[","AutoEncoder","]","(","model\/autoencoder.html",")","*","[","U-Net","]","(","model\/unet.html",")","with","[","attention","]","(","model\/unet_attention.html",")","*","[","CLIP","embeddings","generator","]","(","model\/clip_embedder.html",")"]
docstr: ### Get scaled latent space representation of the image
  
  The encoder output is a distribution.
  We sample from that and multiply by the scaling factor.
docstr_tok: ["#","#","#","Get","scaled","latent","space","representation","of","the","image","The","encoder","output","is","a","distribution",".","We","sample","from","that","and","multiply","by","the","scaling","factor","."]
code: def autoencoder_encode(self, image: torch.Tensor):
      """
      ### Get scaled latent space representation of the image
  
      The encoder output is a distribution.
      We sample from that and multiply by the scaling factor.
      """
      return (
          self.latent_scaling_factor
          * self.first_stage_model.encode(image).sample()
      )
  
file_path: annotated_deep_learning_paper_implementations/labml_nn/diffusion/stable_diffusion/latent_diffusion.py
imports: from typing import List
  import torch
  import torch.nn
  from labml_nn.diffusion.stable_diffusion.model.autoencoder import Autoencoder
  from labml_nn.diffusion.stable_diffusion.model.clip_embedder import CLIPTextEmbedder
  from labml_nn.diffusion.stable_diffusion.model.unet import UNetModel
label_desc: Use image node_id 4 for calling the LatentDiffusion obj's underlying member method code with example usage: obj.autoencoder_encode(image) and returns: unknown