code: def convert_preds_to_outputs(preds, raw_words, mapping, tokenizer):
      """convet model predicitons to BIO outputs
  
      Args:
          preds ([torch.Tensor]): [prompt model predictions, (bsz x seq_len x labels)]
          raw_words ([List]): [source raw words]
          mapping ([dict]): [map entity labels to <<>>]
          tokenizer : [BartTokenizer]
  
      Returns:
          [outputs (List)]: [each item length equal to raw_words, BIO format.]
      """
      id2label = list(mapping.keys())
      pred_eos_index = preds.flip(dims=[1]).eq(1).cumsum(dim=1).long()
      preds = preds[:, 1:]
      pred_seq_len = (
          pred_eos_index.flip(dims=[1])
          .eq(pred_eos_index[:, -1:])
          .sum(dim=1)
      )  # bsz
      pred_seq_len = (pred_seq_len - 2).tolist()
  
      word_start_index = len(mapping) + 2
      outputs = []
      for i, pred_item in enumerate(preds.tolist()):
          pred_item = pred_item[
              : pred_seq_len[i]
          ]  # single sentence prediction
          pairs, cur_pair = [], []
          if len(pred_item):  # this sentence prediciton= is not null
              for idx in pred_item:
                  if idx < word_start_index:  # is entity
                      if len(cur_pair) > 0:
                          # assert word[i] < word[i+1]
                          if all(
                              [
                                  cur_pair[i] < cur_pair[i + 1]
                                  for i in range(len(cur_pair) - 1)
                              ]
                          ):
                              pairs.append(
                                  tuple(cur_pair + [idx])
                              )  # add valid words and current entity id
                      cur_pair = []  # clear word pairs
                  else:  # is word
                      cur_pair.append(idx)  # add word id to word pairs
          raw_words_item = raw_words[i]
          cum_lens = [1]
          start_idx = 1
          for word in raw_words_item:
              start_idx += len(
                  tokenizer.tokenize(word, add_prefix_space=True)
              )
              cum_lens.append(start_idx)
          cum_lens.append(start_idx + 1)
          output = ["O" for _ in range(len(raw_words_item))]
          # pairs: List[(word id, ... , entity id), (...), ...]
          for pair in pairs:  # (word id, ... , entity id)
              entity = pair[-1]
              words = []
              for word in pair[:-1]:
                  if word - word_start_index in cum_lens:
                      words.append(
                          cum_lens.index(word - word_start_index)
                      )
              if len(words) == 0:
                  continue
              start_idx = words[0]
              end_idx = words[-1]
              output[start_idx] = f"B-{id2label[entity-2]}"
              for _ in range(start_idx + 1, end_idx + 1):
                  output[_] = f"I-{id2label[entity-2]}"
          outputs.append(output)
      return outputs
  
file_path: DeepKE/src/deepke/name_entity_re/few_shot/utils/util.py
imports: import torch
  import numpy
  import random
  from torch import nn
  import torch.nn.functional
  from transformers import BartModel, BartTokenizer, BertTokenizer
  import os
label_desc: Use image node_id 6 for calling a global function with example usage: convert_preds_to_outputs(preds, raw_words, mapping, tokenizer) and returns: outputs