class_docstr: Core ML version of
  `diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline`
class_docstr_tok: ["Core","ML","version","of","`","diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline","`"]
code: def prepare_latents(
      self,
      batch_size,
      num_channels_latents,
      height,
      width,
      latents=None,
  ):
      latents_shape = (
          batch_size,
          num_channels_latents,
          self.height // 8,
          self.width // 8,
      )
      if latents is None:
          latents = np.random.randn(*latents_shape).astype(np.float16)
      elif latents.shape != latents_shape:
          raise ValueError(
              f"Unexpected latents shape, got {latents.shape}, expected {latents_shape}"
          )
  
      init_noise = self.scheduler.init_noise_sigma
  
      if isinstance(init_noise, torch.Tensor):
          init_noise = init_noise.numpy()
  
      latents = latents * init_noise
  
      return latents
  
imports: import argparse
  from diffusers import StableDiffusionPipeline, StableDiffusionXLPipeline
  from diffusers.pipelines.pipeline_utils import DiffusionPipeline
  from diffusers.pipelines.stable_diffusion import StableDiffusionPipelineOutput
  from diffusers.schedulers import DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, PNDMScheduler
  from diffusers.schedulers.scheduling_utils import SchedulerMixin
  import gc
  import inspect
  import logging
  import numpy
  import os
  from python_coreml_stable_diffusion.coreml_model import CoreMLModel, _load_mlpackage, _load_mlpackage_controlnet, get_available_compute_units
  import time
  import torch
  from transformers import CLIPFeatureExtractor, CLIPTokenizer
  from typing import List, Optional, Union, Tuple
  from PIL import Image
label_desc: Use image node_id 6 for calling the CoreMLStableDiffusionPipeline obj's underlying member method code with example usage: obj.prepare_latents(batch_size, num_channels_latents, height, width, latents) and returns: latents