code: def encode_prompt(
      text_encoder,
      input_ids,
      attention_mask,
      text_encoder_use_attention_mask=None,
  ):
      text_input_ids = input_ids.to(text_encoder.device)
  
      if text_encoder_use_attention_mask:
          attention_mask = attention_mask.to(text_encoder.device)
      else:
          attention_mask = None
  
      prompt_embeds = text_encoder(
          text_input_ids,
          attention_mask=attention_mask,
      )
      prompt_embeds = prompt_embeds[0]
  
      return 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 4 for calling a global function with example usage: encode_prompt(text_encoder, input_ids, attention_mask, text_encoder_use_attention_mask) and returns: prompt_embeds