code: def build_retag_pipeline(args):
      """
      Builds retag pipelines based on the arguments
  
      May alter the arguments if the pipeline is incompatible, such as
      taggers with no xpos
  
      Will return a list of one or more retag pipelines.
      Multiple tagger models can be specified by having them
      semi-colon separated in retag_model_path.
      """
      # some argument sets might not use 'mode'
      if (
          args["retag_package"] is not None
          and args.get("mode", None) != "remove_optimizer"
      ):
          download_resources_json()
          resources = load_resources_json()
  
          if "_" in args["retag_package"]:
              lang, package = args["retag_package"].split("_", 1)
              lang_resources = get_language_resources(resources, lang)
              if lang_resources is None and "lang" in args:
                  lang_resources = get_language_resources(
                      resources, args["lang"]
                  )
                  if (
                      lang_resources is not None
                      and "pos" in lang_resources
                      and args["retag_package"] in lang_resources["pos"]
                  ):
                      lang = args["lang"]
                      package = args["retag_package"]
          else:
              if "lang" not in args:
                  raise ValueError(
                      "Retag package %s does not specify the language, and it is not clear from the arguments"
                      % args["retag_package"]
                  )
              lang = args.get("lang", None)
              package = args["retag_package"]
          foundation_cache = FoundationCache()
          retag_args = {
              "lang": lang,
              "processors": "tokenize, pos",
              "tokenize_pretokenized": True,
              "package": {"pos": package},
          }
          if args["retag_pretrain_path"] is not None:
              retag_args["pos_pretrain_path"] = args[
                  "retag_pretrain_path"
              ]
          if args["retag_charlm_forward_file"] is not None:
              retag_args["pos_forward_charlm_path"] = args[
                  "retag_charlm_forward_file"
              ]
          if args["retag_charlm_backward_file"] is not None:
              retag_args["pos_backward_charlm_path"] = args[
                  "retag_charlm_backward_file"
              ]
  
          def build(retag_args, path):
              retag_args = copy.deepcopy(retag_args)
              # we just downloaded the resources a moment ago
              # no need to repeatedly download
              retag_args["download_method"] = "reuse_resources"
              if path is not None:
                  retag_args["allow_unknown_language"] = True
                  retag_args["pos_model_path"] = path
  
              retag_pipeline = Pipeline(
                  foundation_cache=foundation_cache, **retag_args
              )
              if args["retag_xpos"] and len(
                  retag_pipeline.processors["pos"].vocab["xpos"]
              ) == len(VOCAB_PREFIX):
                  logger.warning(
                      "XPOS for the %s tagger is empty.  Switching to UPOS",
                      package,
                  )
                  args["retag_xpos"] = False
                  args["retag_method"] = "upos"
              return retag_pipeline
  
          if args["retag_model_path"] is None:
              return [build(retag_args, None)]
          paths = args["retag_model_path"].split(";")
          # can be length 1 if only one tagger to work with
          return [build(retag_args, path) for path in paths]
  
      return None
  
file_path: stanza/stanza/models/constituency/retagging.py
imports: import copy
  import logging
  from stanza import Pipeline
  from stanza.models.common.foundation_cache import FoundationCache
  from stanza.models.common.vocab import VOCAB_PREFIX
  from stanza.resources.common import download_resources_json, load_resources_json, get_language_resources
label_desc: Use image node_id 3 for calling a global function with example usage: build_retag_pipeline(args) and returns: None, unknown, retag_pipeline, list