class_docstr: Pipeline for text-to-image generation using Retrieval Augmented Diffusion.
  
  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:
      vae ([`AutoencoderKL`]):
          Variational Auto-Encoder (VAE) Model to encode and decode images to and from latent representations.
      clip ([`CLIPModel`]):
          Frozen CLIP model. Retrieval Augmented Diffusion uses the CLIP model, specifically the
          [clip-vit-large-patch14](https://huggingface.co/openai/clip-vit-large-patch14) variant.
      tokenizer (`CLIPTokenizer`):
          Tokenizer of class
          [CLIPTokenizer](https://huggingface.co/docs/transformers/v4.21.0/en/model_doc/clip#transformers.CLIPTokenizer).
      unet ([`UNet2DConditionModel`]): Conditional U-Net architecture 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`].
      feature_extractor ([`CLIPFeatureExtractor`]):
          Model that extracts features from generated images to be used as inputs for the `safety_checker`.
class_docstr_tok: ["Pipeline","for","text-to-image","generation","using","Retrieval","Augmented","Diffusion",".","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",":","vae","(","[","`","AutoencoderKL","`","]",")",":","Variational","Auto-Encoder","(","VAE",")","Model","to","encode","and","decode","images","to","and","from","latent","representations",".","clip","(","[","`","CLIPModel","`","]",")",":","Frozen","CLIP","model",".","Retrieval","Augmented","Diffusion","uses","the","CLIP","model",",","specifically","the","[","clip-vit-large-patch14","]","(","https",":","\/\/huggingface.co\/openai\/clip-vit-large-patch14",")","variant",".","tokenizer","(","`","CLIPTokenizer","`",")",":","Tokenizer","of","class","[","CLIPTokenizer","]","(","https",":","\/\/huggingface.co\/docs\/transformers\/v4.21.0\/en\/model_doc\/clip","#","transformers.CLIPTokenizer",")",".","unet","(","[","`","UNet2DConditionModel","`","]",")",":","Conditional","U-Net","architecture","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","`","]",".","feature_extractor","(","[","`","CLIPFeatureExtractor","`","]",")",":","Model","that","extracts","features","from","generated","images","to","be","used","as","inputs","for","the","`","safety_checker","`","."]
code: def _encode_prompt(self, prompt):
      # get prompt text embeddings
      text_inputs = self.tokenizer(
          prompt,
          padding="max_length",
          max_length=self.tokenizer.model_max_length,
          truncation=True,
          return_tensors="pt",
      )
      text_input_ids = text_inputs.input_ids
  
      if text_input_ids.shape[-1] > self.tokenizer.model_max_length:
          removed_text = self.tokenizer.batch_decode(
              text_input_ids[:, self.tokenizer.model_max_length :]
          )
          logger.warning(
              "The following part of your input was truncated because CLIP can only handle sequences up to"
              f" {self.tokenizer.model_max_length} tokens: {removed_text}"
          )
          text_input_ids = text_input_ids[
              :, : self.tokenizer.model_max_length
          ]
      prompt_embeds = self.clip.get_text_features(
          text_input_ids.to(self.device)
      )
      prompt_embeds = prompt_embeds / torch.linalg.norm(
          prompt_embeds, dim=-1, keepdim=True
      )
      prompt_embeds = prompt_embeds[:, None, :]
      return prompt_embeds
  
imports: import inspect
  from typing import Callable, List, Optional, Union
  import torch
  from PIL import Image
  from retriever import Retriever, normalize_images, preprocess_images
  from transformers import CLIPFeatureExtractor, CLIPModel, CLIPTokenizer
  from diffusers import AutoencoderKL, DDIMScheduler, DiffusionPipeline, DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, ImagePipelineOutput, LMSDiscreteScheduler, PNDMScheduler, UNet2DConditionModel, logging
  from diffusers.image_processor import VaeImageProcessor
  from diffusers.utils import is_accelerate_available, randn_tensor
label_desc: Use image node_id 12 for calling the RDMPipeline obj's underlying member method code with example usage: obj._encode_prompt(prompt) and returns: prompt_embeds