code: def main(args=None):
      parser = argparse.ArgumentParser()
      parser.add_argument(
          "infile",
          help="""
              Input for that contains the full SUC 3.0 XML.
              Can be the bz2-zipped version or the xml version.
          """,
      )
      parser.add_argument(
          "outfile",
          nargs="?",
          help="""
               Output file for IOB format.
               Optional - will print to stdout otherwise
          """,
      )
      parser.add_argument(
          "--skiptypes",
          help="Entity types that should be skipped in output.",
          nargs="+",
          default=[],
      )
      parser.add_argument(
          "--stats_only",
          help="Show statistics of found labels at the end of output.",
          action="store_true",
          default=False,
      )
      args = parser.parse_args(args)
  
      MAGIC_BZ2_FILE_START = b"\x42\x5a\x68"
      fp = open(args.infile, "rb")
      is_bz2 = (
          fp.read(len(MAGIC_BZ2_FILE_START)) == MAGIC_BZ2_FILE_START
      )
  
      if is_bz2:
          fp = BZ2File(args.infile, "rb")
      else:
          fp = open(args.infile, "rb")
  
      if args.outfile is not None:
          fout = open(args.outfile, "w", encoding="utf-8")
      else:
          fout = sys.stdout
  
      type_stats = Counter()
      for token in parse(fp, skiptypes=args.skiptypes):
          if not token:
              if not args.stats_only:
                  fout.write("\n")
          else:
              word, prefix, label = token
              if args.stats_only:
                  type_stats[label] += 1
              else:
                  fout.write("%s\t%s%s\n" % (word, prefix, label))
  
      if args.stats_only:
          fout.write(str(type_stats) + "\n")
  
      fp.close()
      if args.outfile is not None:
          fout.close()
  
file_path: stanza/stanza/utils/datasets/ner/suc_to_iob.py
imports: from bz2 import BZ2File
  from xml.etree.ElementTree import iterparse
  import argparse
  from collections import Counter
  import sys
label_desc: Use image node_id 4 for calling a global function with example usage: main(args) without return types