code: def clean_text(tree_str):
      count = 0
      sum_count = 0
  
      tree_str_list = tree_str.split()
  
      for index, char in enumerate(tree_str_list):
          if char == left_bracket:
              count += 1
              sum_count += 1
          elif char == right_bracket:
              count -= 1
              sum_count += 1
          else:
              pass
          if count == 0 and sum_count > 0:
              return " ".join(tree_str_list[: index + 1])
      return " ".join(tree_str_list)
  
imports: from collections import Counter
  import logging
  from nltk.tree import ParentedTree
  import re
  from typing import Tuple, List, Dict
  from ...extraction.constants import null_span, type_start, type_end, span_start
  from ...extraction.predict_parser.predict_parser import PredictParser
  from ...extraction.predict_parser.utils import fix_unk_from_text
label_desc: Use image node_id 5 for calling a global function with example usage: clean_text(tree_str) and returns: str, str