class_docstr: Implementation of `GLIP <https://arxiv.org/abs/2112.03857>`_
  Args:
      backbone (:obj:`ConfigDict` or dict): The backbone config.
      neck (:obj:`ConfigDict` or dict): The neck config.
      bbox_head (:obj:`ConfigDict` or dict): The bbox head config.
      language_model (:obj:`ConfigDict` or dict): The language model config.
      train_cfg (:obj:`ConfigDict` or dict, optional): The training config
          of GLIP. Defaults to None.
      test_cfg (:obj:`ConfigDict` or dict, optional): The testing config
          of GLIP. Defaults to None.
      data_preprocessor (:obj:`ConfigDict` or dict, optional): Config of
          :class:`DetDataPreprocessor` to process the input data.
          Defaults to None.
      init_cfg (:obj:`ConfigDict` or list[:obj:`ConfigDict`] or dict or
          list[dict], optional): Initialization config dict.
          Defaults to None.
class_docstr_tok: ["Implementation","of","`","GLIP","<","https",":","\/\/arxiv.org\/abs\/2112.03857",">","`","_","Args",":","backbone","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","The","backbone","config",".","neck","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","The","neck","config",".","bbox_head","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","The","bbox","head","config",".","language_model","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","The","language","model","config",".","train_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","optional",")",":","The","training","config","of","GLIP",".","Defaults","to","None",".","test_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","optional",")",":","The","testing","config","of","GLIP",".","Defaults","to","None",".","data_preprocessor","(",":","obj",":","`","ConfigDict","`","or","dict",",","optional",")",":","Config","of",":","class",":","`","DetDataPreprocessor","`","to","process","the","input","data",".","Defaults","to","None",".","init_cfg","(",":","obj",":","`","ConfigDict","`","or","list","[",":","obj",":","`","ConfigDict","`","]","or","dict","or","list","[","dict","]",",","optional",")",":","Initialization","config","dict",".","Defaults","to","None","."]
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
  
          if idx != len(original_caption) - 1:
              caption_string += self._special_tokens
      return caption_string, tokens_positive
  
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 2 for calling the GLIP 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