code: def tokenize(
      tokenizer,
      texts: Union[str, List[str]],
      context_length: int = 77,
      truncation=True,
  ):
      if isinstance(texts, str):
          texts = [texts]
  
      sot_token = tokenizer.encoder["<|startoftext|>"]
      eot_token = tokenizer.encoder["<|endoftext|>"]
      all_tokens = [
          [sot_token] + tokenizer.encode(text) + [eot_token]
          for text in texts
      ]
      result = torch.zeros(
          len(all_tokens), context_length, dtype=torch.long
      )
  
      for i, tokens in enumerate(all_tokens):
          if truncation == True:
              tokens = tokens[:context_length]
  
          if len(tokens) > context_length:
              raise RuntimeError(
                  f"Input {texts[i]} is too long for context length {context_length}"
              )
          result[i, : len(tokens)] = torch.tensor(tokens)
  
      return result
  
file_path: backprop/backprop/models/clip/clip.py
imports: import hashlib
  import os
  import urllib
  import warnings
  from typing import Union, List
  import torch
  from PIL import Image
  from torchvision.transforms import Compose, Resize, CenterCrop, ToTensor, Normalize
  from tqdm import tqdm
  from .model import build_model
label_desc: Use image node_id 5 for calling a global function with example usage: tokenize(tokenizer, texts, context_length, truncation) and returns: result