class_docstr: Implementation of `Grounding DINO: Marrying DINO with Grounded Pre-
  Training for Open-Set Object Detection.
  
  <https://arxiv.org/abs/2303.05499>`_
  
  Code is modified from the `official github repo
  <https://github.com/IDEA-Research/GroundingDINO>`_.
class_docstr_tok: ["Implementation","of","`","Grounding","DINO",":","Marrying","DINO","with","Grounded","Pre-","Training","for","Open-Set","Object","Detection",".","<","https",":","\/\/arxiv.org\/abs\/2303.05499",">","`","_","Code","is","modified","from","the","`","official","github","repo","<","https",":","\/\/github.com\/IDEA-Research\/GroundingDINO",">","`","_","."]
code: def to_enhance_text_prompts(
      self, original_caption, enhanced_text_prompts
  ):
      caption_string = ""
      tokens_positive = []
      for idx, word in enumerate(original_caption):
          if word in enhanced_text_prompts:
              enhanced_text_dict = enhanced_text_prompts[word]
              if "prefix" in enhanced_text_dict:
                  caption_string += enhanced_text_dict["prefix"]
              start_i = len(caption_string)
              if "name" in enhanced_text_dict:
                  caption_string += enhanced_text_dict["name"]
              else:
                  caption_string += word
              end_i = len(caption_string)
              tokens_positive.append([[start_i, end_i]])
  
              if "suffix" in enhanced_text_dict:
                  caption_string += enhanced_text_dict["suffix"]
          else:
              tokens_positive.append(
                  [
                      [
                          len(caption_string),
                          len(caption_string) + len(word),
                      ]
                  ]
              )
              caption_string += word
          caption_string += self._special_tokens
      return caption_string, tokens_positive
  
imports: import copy
  import re
  import warnings
  from typing import Dict, Optional, Tuple, Union
  import torch
  import torch.nn
  from torch import Tensor
  from mmdet.registry import MODELS
  from mmdet.structures import OptSampleList, SampleList
  from mmdet.utils import ConfigType
  from ..layers import SinePositionalEncoding
  from ..layers.transformer.grounding_dino_layers import GroundingDinoTransformerDecoder, GroundingDinoTransformerEncoder
  from .dino import DINO
  from .glip import create_positive_map, create_positive_map_label_to_token, run_ner
label_desc: Use image node_id 4 for calling the GroundingDINO obj's underlying member method code with example usage: obj.to_enhance_text_prompts(original_caption, enhanced_text_prompts) and returns: caption_string,  tokens_positive