code: def pad_tokens(
      tokens,
      max_length,
      bos,
      eos,
      pad,
      no_boseos_middle=True,
      chunk_length=77,
  ):
      r"""
      Pad the tokens (with starting and ending tokens) and weights (with 1.0) to max_length.
      """
      max_embeddings_multiples = (max_length - 2) // (chunk_length - 2)
      for i in range(len(tokens)):
          tokens[i] = (
              [bos]
              + tokens[i]
              + [pad] * (max_length - 1 - len(tokens[i]) - 1)
              + [eos]
          )
  
      return 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 2 for calling a global function with example usage: pad_tokens(tokens, max_length, bos, eos, pad, no_boseos_middle, chunk_length) and returns: tokens