def prepare_latents(
        self,
        batch_size,
        num_images_per_prompt,
        height,
        width,
        image: PIL.Image.Image = None,
        latent_timestep: torch.Tensor = None,
    ):
        """Get initial latents for starting generation.

        Args:
            batch_size (int):
                Batch size for generation
            num_images_per_prompt (int):
                Number of images to generate per prompt
            height (int):
                Height of generated image
            width (int):
                Width of generated image
            image (PIL.Image.Image, *optional*, None):
                Input image for generation, if not provided randon noise will be used as starting point
            latent_timestep (torch.Tensor, *optional*, None):
                Predicted by scheduler initial step for image generation, required for latent image mixing with nosie
        Returns:
            latents (np.ndarray):
                Image encoded in latent space

        """
        latents_shape = (batch_size * num_images_per_prompt, 4, height // 8, width // 8)
        noise = np.random.randn(*latents_shape).astype(np.float32)
        if image is None and isinstance(self.scheduler, LMSDiscreteScheduler):
            # if you use LMSDiscreteScheduler, let's make sure latents are multiplied by sigmas
            noise = noise * self.scheduler.sigmas[0].numpy()
            return noise, {}
        input_image, meta = preprocess(image)
        latents = self.vae_encoder(input_image)[self._vae_e_output] * 0.18215
        latents = self.scheduler.add_noise(torch.from_numpy(latents), torch.from_numpy(noise), latent_timestep).numpy()
        return latents, meta
Get initial latents for starting generation.

        Args:
            batch_size (int):
                Batch size for generation
            num_images_per_prompt (int):
                Number of images to generate per prompt
            height (int):
                Height of generated image
            width (int):
                Width of generated image
            image (PIL.Image.Image, *optional*, None):
                Input image for generation, if not provided randon noise will be used as starting point
            latent_timestep (torch.Tensor, *optional*, None):
                Predicted by scheduler initial step for image generation, required for latent image mixing with nosie
        Returns:
            latents (np.ndarray):
                Image encoded in latent space

        
examples/stable_diffusion/sd_utils/ov.py