class_docstr: <Tip warning={true}>
  
  🧪 This is an experimental feature!
  
  </Tip>
  
  Pipeline for image-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.).
  
  Args:
      vae ([`AutoencoderKL`]):
          Variational Auto-Encoder (VAE) model to encode and decode images to and from latent representations.
      image_encoder ([`PaintByExampleImageEncoder`]):
          Encodes the example input image. The `unet` is conditioned on the example image instead of a text prompt.
      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 _encode_image(
      self,
      image,
      device,
      num_images_per_prompt,
      do_classifier_free_guidance,
  ):
      dtype = next(self.image_encoder.parameters()).dtype
  
      if not isinstance(image, torch.Tensor):
          image = self.feature_extractor(
              images=image, return_tensors="pt"
          ).pixel_values
  
      image = image.to(device=device, dtype=dtype)
      image_embeddings, negative_prompt_embeds = self.image_encoder(
          image, return_uncond_vector=True
      )
  
      # duplicate image embeddings for each generation per prompt, using mps friendly method
      bs_embed, seq_len, _ = image_embeddings.shape
      image_embeddings = image_embeddings.repeat(
          1, num_images_per_prompt, 1
      )
      image_embeddings = image_embeddings.view(
          bs_embed * num_images_per_prompt, seq_len, -1
      )
  
      if do_classifier_free_guidance:
          negative_prompt_embeds = negative_prompt_embeds.repeat(
              1, image_embeddings.shape[0], 1
          )
          negative_prompt_embeds = negative_prompt_embeds.view(
              bs_embed * num_images_per_prompt, 1, -1
          )
  
          # For classifier free guidance, we need to do two forward passes.
          # Here we concatenate the unconditional and text embeddings into a single batch
          # to avoid doing two forward passes
          image_embeddings = torch.cat(
              [negative_prompt_embeds, image_embeddings]
          )
  
      return image_embeddings
  
imports: import inspect
  from typing import Callable, List, Optional, Union
  import numpy
  import PIL.Image
  import torch
  from transformers import CLIPImageProcessor
  from ...image_processor import VaeImageProcessor
  from ...models import AutoencoderKL, UNet2DConditionModel
  from ...schedulers import DDIMScheduler, LMSDiscreteScheduler, PNDMScheduler
  from ...utils import deprecate, logging
  from ...utils.torch_utils import randn_tensor
  from ..pipeline_utils import DiffusionPipeline
  from ..stable_diffusion import StableDiffusionPipelineOutput
  from ..stable_diffusion.safety_checker import StableDiffusionSafetyChecker
  from .image_encoder import PaintByExampleImageEncoder
label_desc: Use image node_id 9 for calling the PaintByExamplePipeline obj's underlying member method code with example usage: obj._encode_image(image, device, num_images_per_prompt, do_classifier_free_guidance) and returns: image_embeddings