code: def iob2bioes(tags: List[str]) -> List[str]:
      r"""
      将 ``iob`` 的 tag 转换为 ``bioes`` 编码
  
      :param tags: 需要转换的 tags
      :return:
      """
      new_tags = []
      for i, tag in enumerate(tags):
          if tag == "O":
              new_tags.append(tag)
          else:
              split = tag.split("-")[0]
              if split == "B":
                  if (
                      i + 1 != len(tags)
                      and tags[i + 1].split("-")[0] == "I"
                  ):
                      new_tags.append(tag)
                  else:
                      new_tags.append(tag.replace("B-", "S-"))
              elif split == "I":
                  if (
                      i + 1 < len(tags)
                      and tags[i + 1].split("-")[0] == "I"
                  ):
                      new_tags.append(tag)
                  else:
                      new_tags.append(tag.replace("I-", "E-"))
              else:
                  raise TypeError("Invalid IOB format.")
      return new_tags
  
file_path: fastNLP/fastNLP/io/pipe/utils.py
imports: from typing import List
  from ...core.vocabulary import Vocabulary
  from fastNLP.core.log import logger
  from pkg_resources import parse_version
label_desc: Use image node_id 2 for calling a global function with example usage: iob2bioes(tags) and returns: new_tags