code: def run_ner(caption: str) -> Tuple[list, list]:
      """Run NER on a caption and return the tokens and noun phrases.
      Args:
          caption (str): The input caption.
  
      Returns:
          Tuple[List, List]: A tuple containing the tokens and noun phrases.
              - tokens_positive (List): A list of token positions.
              - noun_phrases (List): A list of noun phrases.
      """
      noun_phrases = find_noun_phrases(caption)
      noun_phrases = [
          remove_punctuation(phrase) for phrase in noun_phrases
      ]
      noun_phrases = [phrase for phrase in noun_phrases if phrase != ""]
      print("noun_phrases:", noun_phrases)
      relevant_phrases = noun_phrases
      labels = noun_phrases
  
      tokens_positive = []
      for entity, label in zip(relevant_phrases, labels):
          try:
              # search all occurrences and mark them as different entities
              # TODO: Not Robust
              for m in re.finditer(entity, caption.lower()):
                  tokens_positive.append([[m.start(), m.end()]])
          except Exception:
              print("noun entities:", noun_phrases)
              print("entity:", entity)
              print("caption:", caption.lower())
      return tokens_positive, noun_phrases
  
imports: import copy
  import re
  import warnings
  from typing import Optional, Tuple, Union
  import torch
  from torch import Tensor
  from mmdet.registry import MODELS
  from mmdet.structures import SampleList
  from mmdet.utils import ConfigType, OptConfigType, OptMultiConfig
  from .single_stage import SingleStageDetector
label_desc: Use image node_id 3 for calling a global function with example usage: run_ner(caption) and returns: tokens_positive,  noun_phrases