class_docstr: Pipeline for generating image prior for Kandinsky
  
  This model inherits from [`DiffusionPipeline`]. Check the superclass documentation for the generic methods the
  library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.)
  
  Args:
      prior ([`PriorTransformer`]):
          The canonincal unCLIP prior to approximate the image embedding from the text embedding.
      image_encoder ([`CLIPVisionModelWithProjection`]):
          Frozen image-encoder.
      text_encoder ([`CLIPTextModelWithProjection`]):
          Frozen text-encoder.
      tokenizer (`CLIPTokenizer`):
          Tokenizer of class
          [CLIPTokenizer](https://huggingface.co/docs/transformers/v4.21.0/en/model_doc/clip#transformers.CLIPTokenizer).
      scheduler ([`UnCLIPScheduler`]):
          A scheduler to be used in combination with `prior` to generate image embedding.
class_docstr_tok: ["Pipeline","for","generating","image","prior","for","Kandinsky","This","model","inherits","from","[","`","DiffusionPipeline","`","]",".","Check","the","superclass","documentation","for","the","generic","methods","the","library","implements","for","all","the","pipelines","(","such","as","downloading","or","saving",",","running","on","a","particular","device",",","etc",".",")","Args",":","prior","(","[","`","PriorTransformer","`","]",")",":","The","canonincal","unCLIP","prior","to","approximate","the","image","embedding","from","the","text","embedding",".","image_encoder","(","[","`","CLIPVisionModelWithProjection","`","]",")",":","Frozen","image-encoder",".","text_encoder","(","[","`","CLIPTextModelWithProjection","`","]",")",":","Frozen","text-encoder",".","tokenizer","(","`","CLIPTokenizer","`",")",":","Tokenizer","of","class","[","CLIPTokenizer","]","(","https",":","\/\/huggingface.co\/docs\/transformers\/v4.21.0\/en\/model_doc\/clip","#","transformers.CLIPTokenizer",")",".","scheduler","(","[","`","UnCLIPScheduler","`","]",")",":","A","scheduler","to","be","used","in","combination","with","`","prior","`","to","generate","image","embedding","."]
code: def _encode_image(
      self,
      image: Union[torch.Tensor, List[PIL.Image.Image]],
      device,
      num_images_per_prompt,
  ):
      if not isinstance(image, torch.Tensor):
          image = self.image_processor(
              image, return_tensors="pt"
          ).pixel_values.to(
              dtype=self.image_encoder.dtype, device=device
          )
  
      image_emb = self.image_encoder(image)["image_embeds"]  # B, D
      image_emb = image_emb.repeat_interleave(
          num_images_per_prompt, dim=0
      )
      image_emb.to(device=device)
  
      return image_emb
  
file_path: llmga/llmga/diffusers/src/diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_prior_emb2emb.py
imports: from typing import List, Optional, Union
  import PIL.Image
  import torch
  from transformers import CLIPImageProcessor, CLIPTextModelWithProjection, CLIPTokenizer, CLIPVisionModelWithProjection
  from ...models import PriorTransformer
  from ...schedulers import UnCLIPScheduler
  from ...utils import logging, replace_example_docstring
  from ...utils.torch_utils import randn_tensor
  from ..kandinsky import KandinskyPriorPipelineOutput
  from ..pipeline_utils import DiffusionPipeline
label_desc: Use image node_id 4 for calling the KandinskyV22PriorEmb2EmbPipeline obj's underlying member method code with example usage: obj._encode_image(image, device, num_images_per_prompt) and returns: image_emb