code: def merge_token_labels_by_bio(token_ranges, labels):
      summary_list = []
      previous_B = None
      for i, label in enumerate(labels):
          # Take action only if the prefix is not i
          if not label.startswith(Slot.I_LABEL_PREFIX):
              # Label the previous chunk
              if previous_B is not None:
                  begin = token_ranges[previous_B][0]
                  end = token_ranges[i - 1][1]
                  summary_list.append(
                      ":".join(
                          [
                              str(begin),
                              str(end),
                              strip_bio_prefix(labels[i - 1]),
                          ]
                      )
                  )
              # Assign the begin location of new chunk
              if label.startswith(Slot.B_LABEL_PREFIX):
                  previous_B = i
              else:  # label == Slot.NO_LABEL_SLOT
                  previous_B = None
  
      # Take last token into account
      if previous_B is not None:
          begin = token_ranges[previous_B][0]
          end = token_ranges[-1][1]
          summary_list.append(
              ":".join(
                  [str(begin), str(end), strip_bio_prefix(labels[-1])]
              )
          )
  
      return summary_list
  
imports: import builtins
  import json
  import os
  import unicodedata
  from typing import Any, List, Optional, Tuple
label_desc: Use image node_id 12 for calling a global function with example usage: merge_token_labels_by_bio(token_ranges, labels) and returns: summary_list