code: def stochastic_encode(
      self, x0, t, use_original_steps=False, noise=None
  ):
      # fast, but does not allow for exact reconstruction
      # t serves as an index to gather the correct alphas
      if use_original_steps:
          sqrt_alphas_cumprod = self.sqrt_alphas_cumprod
          sqrt_one_minus_alphas_cumprod = (
              self.sqrt_one_minus_alphas_cumprod
          )
      else:
          sqrt_alphas_cumprod = torch.sqrt(self.ddim_alphas)
          sqrt_one_minus_alphas_cumprod = (
              self.ddim_sqrt_one_minus_alphas
          )
  
      if noise is None:
          noise = randn_like(x0, generator=self.model.rng)
      return (
          extract_into_tensor(sqrt_alphas_cumprod, t, x0.shape) * x0
          + extract_into_tensor(
              sqrt_one_minus_alphas_cumprod, t, x0.shape
          )
          * noise
      )
  
file_path: NeMo/nemo/collections/multimodal/models/text_to_image/stable_diffusion/samplers/ddim.py
imports: import numpy
  import torch
  from tqdm import tqdm
  from nemo.collections.multimodal.models.text_to_image.stable_diffusion.samplers import Sampler
  from nemo.collections.multimodal.models.text_to_image.stable_diffusion.samplers.base_sampler import AbstractBaseSampler
  from nemo.collections.multimodal.modules.stable_diffusion.diffusionmodules.util import extract_into_tensor
  from nemo.collections.multimodal.parts.utils import randn_like
label_desc: Use image node_id 3 for calling the DDIMSampler obj's underlying member method code with example usage: obj.stochastic_encode(x0, t, use_original_steps, noise) and returns: unknown