code: def process_packages(args):
      """
      Build a package for a language's default processors and all of the treebanks specifically used for that language
      """
      resources = json.load(
          open(os.path.join(args.output_dir, "resources.json"))
      )
  
      for lang in resources:
          # check url, alias, and lang_name in case we are rerunning this step on an already built resources.json
          if lang == "url":
              continue
          if "alias" in resources[lang]:
              continue
          if all(
              k
              in (
                  "backward_charlm",
                  "forward_charlm",
                  "pretrain",
                  "lang_name",
              )
              for k in resources[lang].keys()
          ):
              continue
          if lang not in default_treebanks:
              raise AssertionError(
                  f"{lang} not in default treebanks!!!"
              )
  
          if args.lang and lang != args.lang:
              continue
  
          default_processors = get_default_processors(resources, lang)
  
          # TODO: eventually we can remove default_processors
          # For now, we want to keep this so that v1.5.1 is compatible
          # with the next iteration of resources files
          resources[lang]["default_processors"] = default_processors
          resources[lang][PACKAGES] = {}
          resources[lang][PACKAGES]["default"] = default_processors
  
          if (
              lang not in no_pretrain_languages
              and lang != "multilingual"
          ):
              default_fast = get_default_fast(resources, lang)
              resources[lang][PACKAGES]["default_fast"] = default_fast
  
              default_accurate = get_default_accurate(resources, lang)
              resources[lang][PACKAGES][
                  "default_accurate"
              ] = default_accurate
  
          # Now we loop over each of the tokenizers for this language
          # ... we use this as a proxy for the available UD treebanks
          # This loop also catches things such as "craft" which are
          # included treebanks that aren't UD
          # We then create a package in the packages dict for each of those treebanks
          if "tokenize" in resources[lang]:
              for package in resources[lang]["tokenize"]:
                  processors = {"tokenize": package}
                  if (
                      "mwt" in resources[lang]
                      and package in resources[lang]["mwt"]
                  ):
                      processors["mwt"] = package
  
                  if "pos" in resources[lang]:
                      if package + "_charlm" in resources[lang]["pos"]:
                          processors["pos"] = package + "_charlm"
                      elif (
                          package + "_nocharlm"
                          in resources[lang]["pos"]
                      ):
                          processors["pos"] = package + "_nocharlm"
  
                  if "lemma" in resources[lang] and "pos" in processors:
                      lemma_package = package + "_nocharlm"
                      if lemma_package in resources[lang]["lemma"]:
                          processors["lemma"] = lemma_package
  
                  if (
                      "depparse" in resources[lang]
                      and "pos" in processors
                  ):
                      depparse_package = None
                      if (
                          package + "_charlm"
                          in resources[lang]["depparse"]
                      ):
                          depparse_package = package + "_charlm"
                      elif (
                          package + "_nocharlm"
                          in resources[lang]["depparse"]
                      ):
                          depparse_package = package + "_nocharlm"
                      # we want to set the lemma first if it's identity
                      # THEN set the depparse
                      if depparse_package is not None:
                          if "lemma" not in processors:
                              processors["lemma"] = "identity"
                          processors["depparse"] = depparse_package
  
                  resources[lang][PACKAGES][package] = processors
  
      print("Processed packages.  Writing resources.json")
      json.dump(
          resources,
          open(os.path.join(args.output_dir, "resources.json"), "w"),
          indent=2,
      )
  
imports: import argparse
  from collections import defaultdict
  import json
  import os
  from pathlib import Path
  import hashlib
  import shutil
  import zipfile
  from stanza import __resources_version__
  from stanza.models.common.constant import lcode2lang, two_to_three_letters, three_to_two_letters
  from stanza.resources.default_packages import PACKAGES, TRANSFORMERS, TRANSFORMER_NICKNAMES
  from stanza.resources.default_packages import *
  from stanza.utils.get_tqdm import get_tqdm
label_desc: Use image node_id 31 for calling a global function with example usage: process_packages(args) without return types