code: def choose_tagger_model(short_language, dataset, tagger_model, args):
      """
      Preferentially chooses a retrained tagger model, but tries to download one if that doesn't exist
      """
      if tagger_model:
          return tagger_model
  
      candidates = glob.glob(
          os.path.join(
              args.save_dir, "%s_%s_*.pt" % (short_language, dataset)
          )
      )
      if len(candidates) == 1:
          return candidates[0]
      if len(candidates) > 1:
          for ending in (
              "_trans_tagger.pt",
              "_charlm_tagger.pt",
              "_nocharlm_tagger.pt",
          ):
              best_candidates = [
                  x for x in candidates if x.endswith(ending)
              ]
              if len(best_candidates) == 1:
                  return best_candidates[0]
              if len(best_candidates) > 1:
                  raise FileNotFoundError(
                      "Could not choose among the candidate taggers... please pick one with --tagger_model: {}".format(
                          best_candidates
                      )
                  )
          raise FileNotFoundError(
              "Could not choose among the candidate taggers... please pick one with --tagger_model: {}".format(
                  candidates
              )
          )
  
      if not args.download_tagger:
          return None
  
      # TODO: just create a Pipeline for the retagging instead?
      pos_path = os.path.join(
          DEFAULT_MODEL_DIR, short_language, "pos", dataset + ".pt"
      )
      download(
          lang=short_language, package=None, processors={"pos": dataset}
      )
      return pos_path
  
file_path: stanza/stanza/utils/datasets/prepare_depparse_treebank.py
imports: from enum import Enum
  import glob
  import logging
  import os
  from stanza.models import tagger
  from stanza.models.common.constant import treebank_to_short_name
  from stanza.resources.common import download, DEFAULT_MODEL_DIR
  from stanza.resources.default_packages import default_charlms, pos_charlms
  import stanza.utils.datasets.common
  import stanza.utils.datasets.prepare_tokenizer_treebank
  from stanza.utils.training.run_pos import wordvec_args
  from stanza.utils.training.common import add_charlm_args, build_charlm_args, choose_charlm
label_desc: Use image node_id 2 for calling a global function with example usage: choose_tagger_model(short_language, dataset, tagger_model, args) and returns: pos_path, tagger_model, candidates, None, best_candidates