code: def run_treebank(
      mode,
      paths,
      treebank,
      short_name,
      temp_output_file,
      command_args,
      extra_args,
  ):
      ner_dir = paths["NER_DATA_DIR"]
      language, dataset = short_name.split("_")
  
      train_file = os.path.join(ner_dir, f"{treebank}.train.json")
      dev_file = os.path.join(ner_dir, f"{treebank}.dev.json")
      test_file = os.path.join(ner_dir, f"{treebank}.test.json")
  
      # if any files are missing, try to rebuild the dataset
      # if that still doesn't work, we have to throw an error
      missing_file = [
          x
          for x in (train_file, dev_file, test_file)
          if not os.path.exists(x)
      ]
      if len(missing_file) > 0:
          logger.warning(
              f"The data for {treebank} is missing or incomplete.  Cannot find {missing_file}  Attempting to rebuild..."
          )
          try:
              prepare_ner_dataset.main(treebank)
          except Exception as e:
              raise FileNotFoundError(
                  f"An exception occurred while trying to build the data for {treebank}  At least one portion of the data was missing: {missing_file}  Please correctly build these files and then try again."
              ) from e
  
      pretrain_args = build_pretrain_args(
          language,
          dataset,
          command_args.charlm,
          command_args,
          extra_args,
      )
  
      if mode == Mode.TRAIN:
          # VI example arguments:
          #   --wordvec_pretrain_file ~/stanza_resources/vi/pretrain/vtb.pt
          #   --train_file data/ner/vi_vlsp.train.json
          #   --eval_file data/ner/vi_vlsp.dev.json
          #   --lang vi
          #   --shorthand vi_vlsp
          #   --mode train
          #   --charlm --charlm_shorthand vi_conll17
          #   --dropout 0.6 --word_dropout 0.1 --locked_dropout 0.1 --char_dropout 0.1
          dataset_args = DATASET_EXTRA_ARGS.get(short_name, [])
  
          train_args = [
              "--train_file",
              train_file,
              "--eval_file",
              dev_file,
              "--shorthand",
              short_name,
              "--mode",
              "train",
          ]
          train_args = (
              train_args + pretrain_args + dataset_args + extra_args
          )
          logger.info(
              "Running train step with args: {}".format(train_args)
          )
          ner_tagger.main(train_args)
  
      if mode == Mode.SCORE_DEV or mode == Mode.TRAIN:
          dev_args = [
              "--eval_file",
              dev_file,
              "--shorthand",
              short_name,
              "--mode",
              "predict",
          ]
          dev_args = dev_args + pretrain_args + extra_args
          logger.info("Running dev step with args: {}".format(dev_args))
          ner_tagger.main(dev_args)
  
      if mode == Mode.SCORE_TEST or mode == Mode.TRAIN:
          test_args = [
              "--eval_file",
              test_file,
              "--shorthand",
              short_name,
              "--mode",
              "predict",
          ]
          test_args = test_args + pretrain_args + extra_args
          logger.info(
              "Running test step with args: {}".format(test_args)
          )
          ner_tagger.main(test_args)
  
file_path: stanza/stanza/utils/training/run_ner.py
imports: import logging
  import os
  from stanza.models import ner_tagger
  from stanza.resources.common import DEFAULT_MODEL_DIR
  from stanza.utils.datasets.ner import prepare_ner_dataset
  from stanza.utils.training import common
  from stanza.utils.training.common import Mode, add_charlm_args, build_charlm_args, choose_charlm, find_wordvec_pretrain
  from stanza.resources.default_packages import default_charlms, default_pretrains, ner_charlms, ner_pretrains
label_desc: Use image node_id 4 for calling a global function with example usage: run_treebank(mode, paths, treebank, short_name, temp_output_file, command_args, extra_args) without return types