code: def run_treebank(
      mode,
      paths,
      treebank,
      short_name,
      temp_output_file,
      command_args,
      extra_args,
  ):
      short_language, dataset = short_name.split("_", 1)
  
      lemma_dir = paths["LEMMA_DATA_DIR"]
      train_file = f"{lemma_dir}/{short_name}.train.in.conllu"
      dev_in_file = f"{lemma_dir}/{short_name}.dev.in.conllu"
      dev_gold_file = f"{lemma_dir}/{short_name}.dev.gold.conllu"
      dev_pred_file = (
          temp_output_file
          if temp_output_file
          else f"{lemma_dir}/{short_name}.dev.pred.conllu"
      )
      test_in_file = f"{lemma_dir}/{short_name}.test.in.conllu"
      test_gold_file = f"{lemma_dir}/{short_name}.test.gold.conllu"
      test_pred_file = (
          temp_output_file
          if temp_output_file
          else f"{lemma_dir}/{short_name}.test.pred.conllu"
      )
  
      charlm_args = build_lemma_charlm_args(
          short_language, dataset, command_args.charlm
      )
  
      if not os.path.exists(train_file):
          logger.error(
              "Treebank %s is not prepared for training the lemmatizer.  Could not find any training data at %s  Skipping..."
              % (treebank, train_file)
          )
          return
  
      has_lemmas = check_lemmas(train_file)
      if not has_lemmas:
          logger.info(
              "Treebank "
              + treebank
              + " ("
              + short_name
              + ") has no lemmas.  Using identity lemmatizer"
          )
          if mode == Mode.TRAIN or mode == Mode.SCORE_DEV:
              train_args = [
                  "--train_file",
                  train_file,
                  "--eval_file",
                  dev_in_file,
                  "--output_file",
                  dev_pred_file,
                  "--gold_file",
                  dev_gold_file,
                  "--shorthand",
                  short_name,
              ]
              logger.info(
                  "Running identity lemmatizer for {} with args {}".format(
                      treebank, train_args
                  )
              )
              identity_lemmatizer.main(train_args)
          elif mode == Mode.SCORE_TEST:
              train_args = [
                  "--train_file",
                  train_file,
                  "--eval_file",
                  test_in_file,
                  "--output_file",
                  test_pred_file,
                  "--gold_file",
                  test_gold_file,
                  "--shorthand",
                  short_name,
              ]
              logger.info(
                  "Running identity lemmatizer for {} with args {}".format(
                      treebank, train_args
                  )
              )
              identity_lemmatizer.main(train_args)
      else:
          if mode == Mode.TRAIN:
              # ('UD_Czech-PDT', 'UD_Russian-SynTagRus', 'UD_German-HDT')
              if short_name in ("cs_pdt", "ru_syntagrus", "de_hdt"):
                  num_epochs = "30"
              else:
                  num_epochs = "60"
  
              train_args = [
                  "--train_file",
                  train_file,
                  "--eval_file",
                  dev_in_file,
                  "--output_file",
                  dev_pred_file,
                  "--gold_file",
                  dev_gold_file,
                  "--shorthand",
                  short_name,
                  "--num_epoch",
                  num_epochs,
                  "--mode",
                  "train",
              ]
              train_args = train_args + charlm_args + extra_args
              logger.info(
                  "Running train lemmatizer for {} with args {}".format(
                      treebank, train_args
                  )
              )
              lemmatizer.main(train_args)
  
          if mode == Mode.SCORE_DEV or mode == Mode.TRAIN:
              dev_args = [
                  "--eval_file",
                  dev_in_file,
                  "--output_file",
                  dev_pred_file,
                  "--gold_file",
                  dev_gold_file,
                  "--shorthand",
                  short_name,
                  "--mode",
                  "predict",
              ]
              dev_args = dev_args + charlm_args + extra_args
              logger.info(
                  "Running dev lemmatizer for {} with args {}".format(
                      treebank, dev_args
                  )
              )
              lemmatizer.main(dev_args)
  
          if mode == Mode.SCORE_TEST:
              test_args = [
                  "--eval_file",
                  test_in_file,
                  "--output_file",
                  test_pred_file,
                  "--gold_file",
                  test_gold_file,
                  "--shorthand",
                  short_name,
                  "--mode",
                  "predict",
              ]
              test_args = test_args + charlm_args + extra_args
              logger.info(
                  "Running test lemmatizer for {} with args {}".format(
                      treebank, test_args
                  )
              )
              lemmatizer.main(test_args)
  
file_path: stanza/stanza/utils/training/run_lemma.py
imports: import logging
  import os
  from stanza.models import identity_lemmatizer
  from stanza.models import lemmatizer
  from stanza.utils.training import common
  from stanza.utils.training.common import Mode, add_charlm_args, build_lemma_charlm_args, choose_lemma_charlm
  from stanza.utils.datasets.prepare_lemma_treebank import check_lemmas
label_desc: Use image node_id 3 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