code: def prepare_latents(
      self,
      batch_size,
      num_channels_latents,
      height,
      width,
      dtype,
      generator,
      latents=None,
  ):
      shape = (
          batch_size,
          num_channels_latents,
          height // self.vae_scale_factor,
          width // self.vae_scale_factor,
      )
      if isinstance(generator, list) and len(generator) != batch_size:
          raise ValueError(
              f"You have passed a list of generators of length {len(generator)}, but requested an effective batch"
              f" size of {batch_size}. Make sure the batch size matches the length of the generators."
          )
  
      if latents is None:
          latents = generator.randn(*shape).astype(dtype)
      elif latents.shape != shape:
          raise ValueError(
              f"Unexpected latents shape, got {latents.shape}, expected {shape}"
          )
  
      # scale the initial noise by the standard deviation required by the scheduler
      latents = latents * np.float64(self.scheduler.init_noise_sigma)
  
      return latents
  
file_path: optimum/optimum/pipelines/diffusers/pipeline_stable_diffusion_xl.py
imports: import inspect
  import logging
  from typing import Any, Callable, Dict, List, Optional, Tuple, Union
  import numpy
  import torch
  from diffusers.pipelines.stable_diffusion_xl import StableDiffusionXLPipelineOutput
  from .pipeline_utils import DiffusionPipelineMixin, rescale_noise_cfg
label_desc: Use image node_id 3 for calling the StableDiffusionXLPipelineMixin obj's underlying member method code with example usage: obj.prepare_latents(batch_size, num_channels_latents, height, width, dtype, generator, latents) and returns: latents