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 get_tokens_positive_and_prompts_chunked(
      self,
      original_caption: Union[list, tuple],
      enhanced_text_prompts: Optional[ConfigType] = None,
  ):
      chunked_size = self.test_cfg.get("chunked_size", -1)
      original_caption = [clean_label_name(i) for i in original_caption]
  
      original_caption_chunked = chunks(original_caption, chunked_size)
      ids_chunked = chunks(
          list(range(1, len(original_caption) + 1)), chunked_size
      )
  
      positive_map_label_to_token_chunked = []
      caption_string_chunked = []
      positive_map_chunked = []
      entities_chunked = []
  
      for i in range(len(ids_chunked)):
          if enhanced_text_prompts is not None:
              (
                  caption_string,
                  tokens_positive,
              ) = self.to_enhance_text_prompts(
                  original_caption_chunked[i], enhanced_text_prompts
              )
          else:
              (
                  caption_string,
                  tokens_positive,
              ) = self.to_plain_text_prompts(
                  original_caption_chunked[i]
              )
          tokenized = self.language_model.tokenizer(
              [caption_string], return_tensors="pt"
          )
          if (
              tokenized.input_ids.shape[1]
              > self.language_model.max_tokens
          ):
              warnings.warn(
                  "Inputting a text that is too long will result "
                  "in poor prediction performance. "
                  "Please reduce the --chunked-size."
              )
          (
              positive_map_label_to_token,
              positive_map,
          ) = self.get_positive_map(tokenized, tokens_positive)
  
          caption_string_chunked.append(caption_string)
          positive_map_label_to_token_chunked.append(
              positive_map_label_to_token
          )
          positive_map_chunked.append(positive_map)
          entities_chunked.append(original_caption_chunked[i])
  
      return (
          positive_map_label_to_token_chunked,
          caption_string_chunked,
          positive_map_chunked,
          entities_chunked,
      )
  
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 7 for calling the GLIP obj's underlying member method code with example usage: obj.get_tokens_positive_and_prompts_chunked(original_caption, enhanced_text_prompts) and returns: positive_map_label_to_token_chunked,  caption_string_chunked,  positive_map_chunked,  entities_chunked