code: def decode_from_bioes(tags):
      """
      Decode from a sequence of BIOES tags, assuming default tag is 'O'.
      Args:
          tags: a list of BIOES tags
  
      Returns:
          A list of dict with start_idx, end_idx, and type values.
      """
      res = []
      ent_idxs = []
      cur_type = None
  
      def flush():
          if len(ent_idxs) > 0:
              res.append(
                  {
                      "start": ent_idxs[0],
                      "end": ent_idxs[-1],
                      "type": cur_type,
                  }
              )
  
      for idx, tag in enumerate(tags):
          if tag is None:
              tag = "O"
          if tag == "O":
              flush()
              ent_idxs = []
          elif tag.startswith("B-"):  # start of new ent
              flush()
              ent_idxs = [idx]
              cur_type = tag[2:]
          elif tag.startswith("I-"):  # continue last ent
              ent_idxs.append(idx)
              cur_type = tag[2:]
          elif tag.startswith("E-"):  # end last ent
              ent_idxs.append(idx)
              cur_type = tag[2:]
              flush()
              ent_idxs = []
          elif tag.startswith("S-"):  # start single word ent
              flush()
              ent_idxs = [idx]
              cur_type = tag[2:]
              flush()
              ent_idxs = []
      # flush after whole sentence
      flush()
      return res
  
file_path: stanza/stanza/models/ner/utils.py
imports: import logging
  from stanza.models.common.vocab import EMPTY
label_desc: Use image node_id 8 for calling a global function with example usage: decode_from_bioes(tags) and returns: res