code: def rewrite_label_span(label, span, label_set=None, text=None):
      # Invalid Type
      if label_set and label not in label_set:
          logger.debug("Invalid Label: %s" % label)
          return None, None
  
      # Fix unk using Text
      if text is not None and "<unk>" in span:
          span = fix_unk_from_text(span, text, "<unk>")
  
      # Invalid Text Span
      if text is not None and span not in text:
          logger.debug("Invalid Text Span: %s\n%s\n" % (span, text))
          return None, None
  
      return label, span
  
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 9 for calling a global function with example usage: rewrite_label_span(label, span, label_set, text) and returns: label,  span, None,  None, None,  None