code: def pre_caption(caption, max_words=50):
      caption = re.sub(
          r"([.!\"()*#:;~])",
          " ",
          caption.lower(),
      )
      caption = re.sub(
          r"\s{2,}",
          " ",
          caption,
      )
      caption = caption.rstrip("\n")
      caption = caption.strip(" ")
  
      # truncate caption
      caption_words = caption.split(" ")
      if len(caption_words) > max_words:
          caption = " ".join(caption_words[:max_words])
  
      return caption
  
file_path: blip/data/utils.py
imports: import re
  import json
  import os
  import torch
  import torch.distributed
  import utils
  from pycocotools.coco import COCO
  from pycocoevalcap.eval import COCOEvalCap
  from torchvision.datasets.utils import download_url
label_desc: Use image node_id 1 for calling a global function with example usage: pre_caption(caption, max_words) and returns: caption