code: def get_text_index(
      tokenizer,
      prompt: Union[str, List[str]],
      max_embeddings_multiples: Optional[int] = 4,
      no_boseos_middle: Optional[bool] = False,
  ):
      r"""
      Prompts can be assigned with local weights using brackets. For example,
      prompt 'A (very beautiful) masterpiece' highlights the words 'very beautiful',
      and the embedding tokens corresponding to the words get multiplied by a constant, 1.1.
  
      Also, to regularize of the embedding, the weighted embedding would be scaled to preserve the original mean.
  
      Args:
          pipe (`DiffusionPipeline`):
              Pipe to provide access to the tokenizer and the text encoder.
          prompt (`str` or `List[str]`):
              The prompt or prompts to guide the image generation.
          max_embeddings_multiples (`int`, *optional*, defaults to `3`):
              The max multiple length of prompt embeddings compared to the max output length of text encoder.
          no_boseos_middle (`bool`, *optional*, defaults to `False`):
              If the length of text token is multiples of the capacity of text encoder, whether reserve the starting and
              ending token in each of the chunk in the middle.
      """
      max_length = (
          tokenizer.model_max_length - 2
      ) * max_embeddings_multiples + 2
      if isinstance(prompt, str):
          prompt = [prompt]
  
      prompt_tokens = [
          token[1:-1]
          for token in tokenizer(
              prompt, max_length=max_length, truncation=True
          ).input_ids
      ]
  
      # round up the longest length of tokens to a multiple of (model_max_length - 2)
      max_length = max([len(token) for token in prompt_tokens])
  
      max_embeddings_multiples = min(
          max_embeddings_multiples,
          (max_length - 1) // (tokenizer.model_max_length - 2) + 1,
      )
      max_embeddings_multiples = max(1, max_embeddings_multiples)
      max_length = (
          tokenizer.model_max_length - 2
      ) * max_embeddings_multiples + 2
  
      # pad the length of tokens and weights
      bos = tokenizer.bos_token_id
      eos = tokenizer.eos_token_id
      pad = getattr(tokenizer, "pad_token_id", eos)
      prompt_tokens = pad_tokens(
          prompt_tokens,
          max_length,
          bos,
          eos,
          pad,
          no_boseos_middle=no_boseos_middle,
          chunk_length=tokenizer.model_max_length,
      )
      prompt_tokens = torch.tensor(prompt_tokens, dtype=torch.long)
  
      return prompt_tokens
  
file_path: llmga/llmga/diffusers/my_utils/util.py
imports: import numpy
  import PIL.Image
  import torch
  from diffusers.utils import PIL_INTERPOLATION, deprecate, is_accelerate_available, is_accelerate_version, logging
  from diffusers.utils.torch_utils import randn_tensor
  import inspect
  import re
  from typing import Any, Callable, Dict, List, Optional, Union
label_desc: Use image node_id 6 for calling a global function with example usage: get_text_index(tokenizer, prompt, max_embeddings_multiples, no_boseos_middle) and returns: prompt_tokens