code: def convert_file(input_filename, output_filename, pipe):
      with open(input_filename) as fin:
          lines = fin.readlines()
  
      all_labels = set()
  
      with open(output_filename, "w") as fout:
          for line in tqdm(lines):
              pieces = line.split("|")
              texts = []
              labels = []
              skip_sentence = False
              for piece in pieces:
                  piece = piece.strip()
                  if not piece:
                      continue
                  text, label = piece.rsplit("@", maxsplit=1)
                  text = text.strip()
                  if not text:
                      continue
                  if label == "SB":
                      skip_sentence = True
                      break
  
                  texts.append(text)
                  labels.append(label)
  
              if skip_sentence:
                  continue
  
              text = "\n\n".join(texts)
              doc = pipe(text)
              assert len(doc.sentences) == len(texts)
              for sentence, label in zip(doc.sentences, labels):
                  all_labels.add(label)
                  for word_idx, word in enumerate(sentence.words):
                      if label == "O":
                          output_label = "O"
                      elif word_idx == 0:
                          output_label = "B-" + label
                      else:
                          output_label = "I-" + label
  
                      fout.write("%s\t%s\n" % (word.text, output_label))
              fout.write("\n\n")
  
      print(
          "Finished processing {}  Labels found: {}".format(
              input_filename, sorted(all_labels)
          )
      )
  
imports: import os
  from tqdm import tqdm
  import stanza
  from stanza.utils.datasets.ner.check_for_duplicates import check_for_duplicates
label_desc: Use image node_id 1 for calling a global function with example usage: convert_file(input_filename, output_filename, pipe) without return types