code: def check_for_positive_overflow(
      gt_bboxes, gt_labels, text, tokenizer, max_tokens
  ):
      # Check if we have too many positive labels
      # generate a caption by appending the positive labels
      positive_label_list = np.unique(gt_labels).tolist()
      # random shuffule so we can sample different annotations
      # at different epochs
      random.shuffle(positive_label_list)
  
      kept_lables = []
      length = 0
  
      for index, label in enumerate(positive_label_list):
          label_text = clean_name(text[str(label)]) + ". "
  
          tokenized = tokenizer.tokenize(label_text)
  
          length += len(tokenized)
  
          if length > max_tokens:
              break
          else:
              kept_lables.append(label)
  
      keep_box_index = []
      keep_gt_labels = []
      for i in range(len(gt_labels)):
          if gt_labels[i] in kept_lables:
              keep_box_index.append(i)
              keep_gt_labels.append(gt_labels[i])
  
      return (
          gt_bboxes[keep_box_index],
          np.array(keep_gt_labels, dtype=np.long),
          length,
      )
  
file_path: mmdetection/mmdet/datasets/transforms/text_transformers.py
imports: import json
  from mmcv.transforms import BaseTransform
  from mmdet.registry import TRANSFORMS
  from mmdet.structures.bbox import BaseBoxes
  import random
  import re
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: check_for_positive_overflow(gt_bboxes, gt_labels, text, tokenizer, max_tokens) and returns: gt_bboxes,  np,  length