class_docstr: Pipeline for text-guided image inpainting using Stable Diffusion.
  
  This model inherits from [`DiffusionPipeline`]. Check the superclass documentation for the generic methods
  implemented for all pipelines (downloading, saving, running on a particular device, etc.).
  
  The pipeline also inherits the following loading methods:
      - [`~loaders.TextualInversionLoaderMixin.load_textual_inversion`] for loading textual inversion embeddings
      - [`~loaders.LoraLoaderMixin.load_lora_weights`] for loading LoRA weights
      - [`~loaders.LoraLoaderMixin.save_lora_weights`] for saving LoRA weights
  
  Args:
      vae ([`AutoencoderKL`, `AsymmetricAutoencoderKL`]):
          Variational Auto-Encoder (VAE) Model to encode and decode images to and from latent representations.
      text_encoder ([`CLIPTextModel`]):
          Frozen text-encoder ([clip-vit-large-patch14](https://huggingface.co/openai/clip-vit-large-patch14)).
      tokenizer ([`~transformers.CLIPTokenizer`]):
          A `CLIPTokenizer` to tokenize text.
      unet ([`UNet2DConditionModel`]):
          A `UNet2DConditionModel` to denoise the encoded image latents.
      scheduler ([`SchedulerMixin`]):
          A scheduler to be used in combination with `unet` to denoise the encoded image latents. Can be one of
          [`DDIMScheduler`], [`LMSDiscreteScheduler`], or [`PNDMScheduler`].
      safety_checker ([`StableDiffusionSafetyChecker`]):
          Classification module that estimates whether generated images could be considered offensive or harmful.
          Please refer to the [model card](https://huggingface.co/runwayml/stable-diffusion-v1-5) for more details
          about a model's potential harms.
      feature_extractor ([`~transformers.CLIPImageProcessor`]):
          A `CLIPImageProcessor` to extract features from generated images; used as inputs to the `safety_checker`.
code: def prepare_mask_latents(
      self,
      mask,
      masked_image,
      batch_size,
      height,
      width,
      dtype,
      device,
      generator,
      do_classifier_free_guidance,
  ):
      # resize the mask to latents shape as we concatenate the mask to the latents
      # we do that before converting to dtype to avoid breaking in case we're using cpu_offload
      # and half precision
      mask = torch.nn.functional.interpolate(
          mask,
          size=(
              height // self.vae_scale_factor,
              width // self.vae_scale_factor,
          ),
      )
      mask = mask.to(device=device, dtype=dtype)
  
      masked_image = masked_image.to(device=device, dtype=dtype)
  
      if masked_image.shape[1] == 4:
          masked_image_latents = masked_image
      else:
          masked_image_latents = self._encode_vae_image(
              masked_image, generator=generator
          )
  
      # duplicate mask and masked_image_latents for each generation per prompt, using mps friendly method
      if mask.shape[0] < batch_size:
          if not batch_size % mask.shape[0] == 0:
              raise ValueError(
                  "The passed mask and the required batch size don't match. Masks are supposed to be duplicated to"
                  f" a total batch size of {batch_size}, but {mask.shape[0]} masks were passed. Make sure the number"
                  " of masks that you pass is divisible by the total requested batch size."
              )
          mask = mask.repeat(batch_size // mask.shape[0], 1, 1, 1)
      if masked_image_latents.shape[0] < batch_size:
          if not batch_size % masked_image_latents.shape[0] == 0:
              raise ValueError(
                  "The passed images and the required batch size don't match. Images are supposed to be duplicated"
                  f" to a total batch size of {batch_size}, but {masked_image_latents.shape[0]} images were passed."
                  " Make sure the number of images that you pass is divisible by the total requested batch size."
              )
          masked_image_latents = masked_image_latents.repeat(
              batch_size // masked_image_latents.shape[0], 1, 1, 1
          )
  
      mask = (
          torch.cat([mask] * 2) if do_classifier_free_guidance else mask
      )
      masked_image_latents = (
          torch.cat([masked_image_latents] * 2)
          if do_classifier_free_guidance
          else masked_image_latents
      )
  
      # aligning device to prevent device errors when concating it with the latent model input
      masked_image_latents = masked_image_latents.to(
          device=device, dtype=dtype
      )
      return mask, masked_image_latents
  
imports: import inspect
  from typing import Any, Callable, Dict, List, Optional, Union
  import numpy
  import PIL.Image
  import torch
  from packaging import version
  from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer
  from ...configuration_utils import FrozenDict
  from ...image_processor import PipelineImageInput, VaeImageProcessor
  from ...loaders import FromSingleFileMixin, LoraLoaderMixin, TextualInversionLoaderMixin
  from ...models import AsymmetricAutoencoderKL, AutoencoderKL, UNet2DConditionModel
  from ...models.lora import adjust_lora_scale_text_encoder
  from ...schedulers import KarrasDiffusionSchedulers
  from ...utils import USE_PEFT_BACKEND, deprecate, logging, scale_lora_layers, unscale_lora_layers
  from ...utils.torch_utils import randn_tensor
  from ..pipeline_utils import DiffusionPipeline
  from .None import StableDiffusionPipelineOutput
  from .safety_checker import StableDiffusionSafetyChecker
label_desc: Use image node_id 9 for calling the StableDiffusionInpaintPipeline obj's underlying member method code with example usage: obj.prepare_mask_latents(mask, masked_image, batch_size, height, width, dtype, device, generator, do_classifier_free_guidance) and returns: mask,  masked_image_latents