code: def encode_prompt_xl(
      text_encoders, tokenizers, prompt, text_input_ids_list=None
  ):
      prompt_embeds_list = []
      # logger.info(f"Computing text embeddings for prompt: {prompt}")
      # logger.info(f"Text encoders: {text_encoders}")
      # logger.info(f"Tokenizers: {tokenizers}")
  
      for i, text_encoder in enumerate(text_encoders):
          if tokenizers is not None:
              tokenizer = tokenizers[i]
              text_input_ids = tokenize_prompt(
                  tokenizer, prompt
              ).input_ids
              # logger.info(f"Text input ids: {text_input_ids}")
          else:
              assert text_input_ids_list is not None
              text_input_ids = text_input_ids_list[i]
  
          prompt_embeds = text_encoder(
              text_input_ids.to(text_encoder.device),
              output_hidden_states=True,
          )
  
          # We are only ALWAYS interested in the pooled output of the final text encoder
          pooled_prompt_embeds = prompt_embeds[0]
          prompt_embeds = prompt_embeds.hidden_states[-2]
          bs_embed, seq_len, _ = prompt_embeds.shape
          prompt_embeds = prompt_embeds.view(bs_embed, seq_len, -1)
          prompt_embeds_list.append(prompt_embeds)
  
      prompt_embeds = torch.concat(prompt_embeds_list, dim=-1)
      pooled_prompt_embeds = pooled_prompt_embeds.view(bs_embed, -1)
      return prompt_embeds, pooled_prompt_embeds
  
imports: import hashlib
  import itertools
  import os
  from pathlib import Path
  from typing import Dict
  import torch
  from diffusers import AutoencoderKL, DDPMScheduler, DiffusionPipeline, StableDiffusionXLPipeline, UNet2DConditionModel
  from diffusers.utils.import_utils import is_xformers_available
  from packaging import version
  from tqdm import tqdm
  from transformers import AutoTokenizer, PretrainedConfig
  from autotrain import logger
  from autotrain.trainers.dreambooth.datasets import PromptDataset
label_desc: Use image node_id 5 for calling a global function with example usage: encode_prompt_xl(text_encoders, tokenizers, prompt, text_input_ids_list) and returns: prompt_embeds,  pooled_prompt_embeds