docstr: Encodes the prompt into text encoder hidden states.
  Args:
      prompt (`str` or `List[str]`, *optional*):
          prompt to be encoded
      device: (`torch.device`):
          torch device
      num_images_per_prompt (`int`):
          number of images that should be generated per prompt
      prompt_embeds (`torch.FloatTensor`, *optional*):
          Pre-generated text embeddings. Can be used to easily tweak text inputs, *e.g.* prompt weighting. If not
          provided, text embeddings will be generated from `prompt` input argument.
docstr_tok: ["Encodes","the","prompt","into","text","encoder","hidden","states",".","Args",":","prompt","(","`","str","`","or","`","List","[","str","]","`",",","*","optional","*",")",":","prompt","to","be","encoded","device",":","(","`","torch.device","`",")",":","torch","device","num_images_per_prompt","(","`","int","`",")",":","number","of","images","that","should","be","generated","per","prompt","prompt_embeds","(","`","torch.FloatTensor","`",",","*","optional","*",")",":","Pre-generated","text","embeddings",".","Can","be","used","to","easily","tweak","text","inputs",",","*","e.g",".","*","prompt","weighting",".","If","not","provided",",","text","embeddings","will","be","generated","from","`","prompt","`","input","argument","."]
code: def _encode_prompt(
      self,
      prompt,
      device,
      num_images_per_prompt,
      prompt_embeds: None,
  ):
      r"""
      Encodes the prompt into text encoder hidden states.
      Args:
          prompt (`str` or `List[str]`, *optional*):
              prompt to be encoded
          device: (`torch.device`):
              torch device
          num_images_per_prompt (`int`):
              number of images that should be generated per prompt
          prompt_embeds (`torch.FloatTensor`, *optional*):
              Pre-generated text embeddings. Can be used to easily tweak text inputs, *e.g.* prompt weighting. If not
              provided, text embeddings will be generated from `prompt` input argument.
      """
  
      if prompt is not None and isinstance(prompt, str):
          pass
      elif prompt is not None and isinstance(prompt, list):
          len(prompt)
      else:
          prompt_embeds.shape[0]
  
      if prompt_embeds is None:
          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
          untruncated_ids = self.tokenizer(
              prompt, padding="longest", return_tensors="pt"
          ).input_ids
  
          if untruncated_ids.shape[-1] >= text_input_ids.shape[
              -1
          ] and not torch.equal(text_input_ids, untruncated_ids):
              removed_text = self.tokenizer.batch_decode(
                  untruncated_ids[
                      :, self.tokenizer.model_max_length - 1 : -1
                  ]
              )
              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}"
              )
  
          if (
              hasattr(self.text_encoder.config, "use_attention_mask")
              and self.text_encoder.config.use_attention_mask
          ):
              attention_mask = text_inputs.attention_mask.to(device)
          else:
              attention_mask = None
  
          prompt_embeds = self.text_encoder(
              text_input_ids.to(device),
              attention_mask=attention_mask,
          )
          prompt_embeds = prompt_embeds[0]
  
      if self.text_encoder is not None:
          prompt_embeds_dtype = self.text_encoder.dtype
      elif self.unet is not None:
          prompt_embeds_dtype = self.unet.dtype
      else:
          prompt_embeds_dtype = prompt_embeds.dtype
  
      prompt_embeds = prompt_embeds.to(
          dtype=prompt_embeds_dtype, device=device
      )
  
      bs_embed, seq_len, _ = prompt_embeds.shape
      # duplicate text embeddings for each generation per prompt, using mps friendly method
      prompt_embeds = prompt_embeds.repeat(1, num_images_per_prompt, 1)
      prompt_embeds = prompt_embeds.view(
          bs_embed * num_images_per_prompt, seq_len, -1
      )
  
      # Don't need to get uncond prompt embedding because of LCM Guided Distillation
      return prompt_embeds
  
imports: import math
  from dataclasses import dataclass
  from typing import Any, Dict, List, Optional, Tuple, Union
  import numpy
  import torch
  from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer
  from diffusers import AutoencoderKL, ConfigMixin, DiffusionPipeline, SchedulerMixin, UNet2DConditionModel, logging
  from diffusers.configuration_utils import register_to_config
  from diffusers.image_processor import VaeImageProcessor
  from diffusers.pipelines.stable_diffusion import StableDiffusionPipelineOutput
  from diffusers.pipelines.stable_diffusion.safety_checker import StableDiffusionSafetyChecker
  from diffusers.utils import BaseOutput
label_desc: Use image node_id 2 for calling the LatentConsistencyModelPipeline obj's underlying member method code with example usage: obj._encode_prompt(prompt, device, num_images_per_prompt, prompt_embeds) and returns: prompt_embeds