code: def write_dataset(
      datasets,
      output_dir,
      short_name,
      suffix="bio",
      shard_names=SHARDS,
      shards=SHARDS,
  ):
      """
      write all three pieces of a dataset to output_dir
  
      datasets should be 3 lists: train, dev, test
      each list should be a list of sentences
      each sentence is a list of pairs: word, tag
  
      after writing to .bio files, the files will be converted to .json
      """
      for shard, dataset in zip(shard_names, datasets):
          output_filename = os.path.join(
              output_dir, "%s.%s.%s" % (short_name, shard, suffix)
          )
          write_sentences(output_filename, dataset)
  
      convert_bio_to_json(
          output_dir,
          output_dir,
          short_name,
          suffix,
          shard_names=shard_names,
          shards=shards,
      )
  
imports: from collections import defaultdict
  import json
  import os
  import random
  from stanza.models.common.doc import Document
  import stanza.utils.datasets.ner.prepare_ner_file
label_desc: Use image node_id 4 for calling a global function with example usage: write_dataset(datasets, output_dir, short_name, suffix, shard_names, shards) without return types