code: def get_xpos_factory(shorthand, fn):
      logger.info("Resolving vocab option for {}...".format(shorthand))
      train_file = os.path.join(
          DATA_DIR, "{}.train.in.conllu".format(shorthand)
      )
      if not os.path.exists(train_file):
          raise UserWarning(
              "Training data for {} not found in the data directory, falling back to using WordVocab. To generate the "
              "XPOS vocabulary for this treebank properly, please run the following command first:\n"
              "\tstanza/utils/datasets/prepare_pos_treebank.py {}".format(
                  fn, fn
              )
          )
          # without the training file, there's not much we can do
          key = DEFAULT_KEY
          return key
  
      doc = CoNLL.conll2doc(input_file=train_file)
      data = doc.get([TEXT, UPOS, XPOS, FEATS], as_sentences=True)
      return choose_simplest_factory(data, shorthand)
  
file_path: stanza/stanza/models/pos/build_xpos_vocab_factory.py
imports: import argparse
  from collections import defaultdict
  import logging
  import os
  import re
  import sys
  from stanza.models.common.constant import treebank_to_short_name
  from stanza.models.pos.xpos_vocab_utils import DEFAULT_KEY, choose_simplest_factory, XPOSType
  from stanza.models.common.doc import *
  from stanza.utils.conll import CoNLL
  from stanza.utils import default_paths
label_desc: Use image node_id 1 for calling a global function with example usage: get_xpos_factory(shorthand, fn) and returns: choose_simplest_factory, key