code: def split_to_spans(s: Sentence, label_name="ner"):
      orig = s.to_original_text()
      last_idx = 0
      spans = []
      tagged_ents = s.get_labels(label_name)
      for ent in tagged_ents:
          if last_idx != ent.data_point.start_position:
              spans.append(
                  (orig[last_idx : ent.data_point.start_position], None)
              )
          spans.append((ent.data_point.text, ent.value))
          assert ent.data_point.end_position is not None
          last_idx = ent.data_point.end_position
      if last_idx < len(orig) - 1:
          spans.append((orig[last_idx : len(orig)], None))
      return spans
  
imports: import html
  from typing import List, Union
  from flair.data import Sentence
label_desc: Use image node_id 1 for calling a global function with example usage: split_to_spans(s, label_name) and returns: spans