code: def _bioes_tag_to_spans(tags, ignore_labels=None):
      r"""
      给定一个 tags 的 lis，比如 ['O', 'B-singer', 'I-singer', 'E-singer', 'O', 'O']。
      返回 [('singer', (1, 4))] (左闭右开区间)
  
      :param tags: List[str],
      :param ignore_labels: List[str], 在该list中的label将被忽略
      :return: List[Tuple[str, List[int, int]]]. [(label，[start, end])]
      """
      ignore_labels = set(ignore_labels) if ignore_labels else set()
  
      spans = []
      prev_bioes_tag = None
      for idx, tag in enumerate(tags):
          tag = tag.lower()
          bioes_tag, label = tag[:1], tag[2:]
          if bioes_tag in ("b", "s"):
              spans.append((label, [idx, idx]))
          elif (
              bioes_tag in ("i", "e")
              and prev_bioes_tag in ("b", "i")
              and label == spans[-1][0]
          ):
              spans[-1][1][1] = idx
          elif bioes_tag == "o":
              pass
          else:
              spans.append((label, [idx, idx]))
          prev_bioes_tag = bioes_tag
      return [
          (span[0], (span[1][0], span[1][1] + 1))
          for span in spans
          if span[0] not in ignore_labels
      ]
  
file_path: fastNLP/fastNLP/core/metrics/span_f1_pre_rec_metric.py
imports: from typing import Union, List, Optional
  from collections import Counter
  from fastNLP.core.metrics.backend import Backend
  from fastNLP.core.metrics.metric import Metric
  from fastNLP.core.vocabulary import Vocabulary
  from fastNLP.core.log import logger
  from .utils import _compute_f_pre_rec
label_desc: Use image node_id 5 for calling a global function with example usage: _bioes_tag_to_spans(tags, ignore_labels) and returns: unknown