code: def pre_compute_text_embeddings(config, tokenizers, text_encoders):
      if config.pre_compute_text_embeddings:
          tokenizer = tokenizers[0]
          text_encoder = text_encoders[0]
  
          def compute_text_embeddings(prompt):
              with torch.no_grad():
                  text_inputs = tokenize_prompt(
                      tokenizer,
                      prompt,
                      tokenizer_max_length=config.tokenizer_max_length,
                  )
                  prompt_embeds = encode_prompt(
                      text_encoder,
                      text_inputs.input_ids,
                      text_inputs.attention_mask,
                      text_encoder_use_attention_mask=config.text_encoder_use_attention_mask,
                  )
  
              return prompt_embeds
  
          pre_computed_encoder_hidden_states = compute_text_embeddings(
              config.prompt
          )
  
          # disable validation prompt for now
          # validation_prompt_negative_prompt_embeds = compute_text_embeddings("")
  
          # if args.validation_prompt is not None:
          #     validation_prompt_encoder_hidden_states = compute_text_embeddings(args.validation_prompt)
          # else:
          #     validation_prompt_encoder_hidden_states = None
  
          if config.prompt is not None:
              pre_computed_instance_prompt_encoder_hidden_states = (
                  compute_text_embeddings(config.prompt)
              )
          else:
              pre_computed_instance_prompt_encoder_hidden_states = None
  
      else:
          pre_computed_encoder_hidden_states = None
          # validation_prompt_encoder_hidden_states = None
          pre_computed_instance_prompt_encoder_hidden_states = None
  
      return (
          pre_computed_encoder_hidden_states,
          pre_computed_instance_prompt_encoder_hidden_states,
      )
  
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 12 for calling a global function with example usage: pre_compute_text_embeddings(config, tokenizers, text_encoders) and returns: pre_computed_encoder_hidden_states,  pre_computed_instance_prompt_encoder_hidden_states, prompt_embeds