code: def decode_bbox_from_caption(text, img_w, img_h, verbose=False):
      entities = []
      boxes = []
  
      start = 0
      in_brackets = False
      entity = ""
      box = ""
  
      for i, char in enumerate(text):
          if char == "[":
              in_brackets = True
              entity = text[start:i].strip()
              start = i + 1
          elif char == "]":
              in_brackets = False
              box = text[start:i].strip()
              start = i + 1
  
              # Convert box string to list of integers
              box_list = list(map(int, box.split(",")))
              resized_box_list = resize_bbox(box_list, img_w, img_h)
              entities.append(entity)
              boxes.append(resized_box_list)
  
              # Skip until the next entity (ignoring periods or other delimiters)
              while start < len(text) and text[start] not in [
                  ".",
                  ",",
                  ";",
                  "!",
                  "?",
              ]:
                  start += 1
              start += 1  # Skip the delimiter
  
      return entities, boxes
  
file_path: ml-ferret/ferret/eval/eval_refexp.py
imports: import os
  import copy
  from collections import defaultdict
  from pathlib import Path
  from tqdm import tqdm
  import torch
  import torch.utils.data
  from typing import Any, Dict, List, Optional, Sequence, Tuple, Union
  from prettytable import PrettyTable
  import re
  import json
  from misc.refcoco.box_ops import generalized_box_iou, box_iou
label_desc: Use image node_id 2 for calling a global function with example usage: decode_bbox_from_caption(text, img_w, img_h, verbose) and returns: entities,  boxes