class_docstr: Pipeline to generate image variations from an input image 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 ([`~transformers.CLIPVisionModelWithProjection`]):
          Frozen CLIP image-encoder ([clip-vit-large-patch14](https://huggingface.co/openai/clip-vit-large-patch14)).
      text_encoder ([`~transformers.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`.
class_docstr_tok: ["Pipeline","to","generate","image","variations","from","an","input","image","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","(","[","`","~transformers.CLIPVisionModelWithProjection","`","]",")",":","Frozen","CLIP","image-encoder","(","[","clip-vit-large-patch14","]","(","https",":","\/\/huggingface.co\/openai\/clip-vit-large-patch14",")",")",".","text_encoder","(","[","`","~transformers.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 _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 = self.image_encoder(image).image_embeds
      image_embeddings = image_embeddings.unsqueeze(1)
  
      # 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 = torch.zeros_like(image_embeddings)
  
          # 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 PIL.Image
  import torch
  from packaging import version
  from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection
  from ...configuration_utils import FrozenDict
  from ...image_processor import VaeImageProcessor
  from ...models import AutoencoderKL, UNet2DConditionModel
  from ...schedulers import KarrasDiffusionSchedulers
  from ...utils import deprecate, logging
  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 2 for calling the StableDiffusionImageVariationPipeline 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