code: def write_sentences(output_filename, annotated_sentences):
      logger.info(
          "Writing %d sentences to %s"
          % (len(annotated_sentences), output_filename)
      )
      with open(output_filename, "w") as fout:
          for sentence in annotated_sentences:
              for token in sentence.tokens:
                  ner_tag = token.ner
                  if not ner_tag:
                      ner_tag = "O"
                  fout.write("%s\t%s\n" % (token.text, ner_tag))
              fout.write("\n")
  
file_path: stanza/stanza/utils/datasets/ner/convert_bsnlp.py
imports: import argparse
  import glob
  import os
  import logging
  import random
  import re
  import stanza
label_desc: Use image node_id 4 for calling a global function with example usage: write_sentences(output_filename, annotated_sentences) without return types