code: def maintain_processor_list(
      resources,
      lang,
      package,
      processors,
      allow_pretrain=False,
      maybe_add_mwt=True,
  ):
      """
      Given a parsed resources file, language, and possible package
      and/or processors, expands the package to the list of processors
  
      Returns a list of processors
      Each item in the list of processors is a pair:
        name, then a list of ModelSpecification
      so, for example:
        [['pos', [ModelSpecification(processor='pos', package='gsd', dependencies=None)]],
         ['depparse', [ModelSpecification(processor='depparse', package='gsd', dependencies=None)]]]
      """
      processor_list = defaultdict(list)
      # resolve processor models
      if processors:
          logger.debug(f'Processing parameter "processors"...')
          if (
              maybe_add_mwt
              and TOKENIZE in processors
              and MWT not in processors
          ):
              add_mwt(processors, resources, lang)
          for key, plist in processors.items():
              if not isinstance(key, str):
                  raise ValueError("Processor names must be strings")
              if not isinstance(plist, (tuple, list, str)):
                  raise ValueError("Processor values must be strings")
              if isinstance(plist, str):
                  plist = [plist]
              if key not in PIPELINE_NAMES:
                  if not allow_pretrain or key not in PRETRAIN_NAMES:
                      raise UnknownProcessorError(key)
              for value in plist:
                  # check if keys and values can be found
                  if (
                      key in resources[lang]
                      and value in resources[lang][key]
                  ):
                      logger.debug(f"Found {key}: {value}.")
                      processor_list[key].append(value)
                  # allow values to be default in some cases
                  elif (
                      value in resources[lang][PACKAGES]
                      and key in resources[lang][PACKAGES][value]
                  ):
                      logger.debug(
                          f"Found {key}: {resources[lang][PACKAGES][value][key]}."
                      )
                      processor_list[key].append(
                          resources[lang][PACKAGES][value][key]
                      )
                  # optional defaults will be activated if specifically turned on
                  elif (
                      value in resources[lang][PACKAGES]
                      and "optional" in resources[lang][PACKAGES][value]
                      and key
                      in resources[lang][PACKAGES][value]["optional"]
                  ):
                      logger.debug(
                          f"Found {key}: {resources[lang][PACKAGES][value]['optional'][key]}."
                      )
                      processor_list[key].append(
                          resources[lang][PACKAGES][value]["optional"][
                              key
                          ]
                      )
                  # allow processors to be set to variants that we didn't implement
                  elif value in PROCESSOR_VARIANTS[key]:
                      logger.debug(
                          f"Found {key}: {value}. "
                          f"Using external {value} variant for the {key} processor."
                      )
                      processor_list[key].append(value)
                  # allow lemma to be set to "identity"
                  elif key == LEMMA and value == "identity":
                      logger.debug(
                          f"Found {key}: {value}. Using identity lemmatizer."
                      )
                      processor_list[key].append(value)
                  # not a processor in the officially supported processor list
                  elif key not in resources[lang]:
                      logger.debug(
                          f"{key}: {value} is not officially supported by Stanza, "
                          f"loading it anyway."
                      )
                      processor_list[key].append(value)
                  # cannot find the package for a processor and warn user
                  else:
                      logger.warning(
                          f"Can not find {key}: {value} from official model list. "
                          f"Ignoring it."
                      )
      # resolve package
      if package:
          logger.debug(f'Processing parameter "package"...')
          if (
              PACKAGES in resources[lang]
              and package in resources[lang][PACKAGES]
          ):
              for key, value in resources[lang][PACKAGES][
                  package
              ].items():
                  if key != "optional" and key not in processor_list:
                      logger.debug(f"Found {key}: {value}.")
                      processor_list[key].append(value)
          else:
              flag = False
              for key in PIPELINE_NAMES:
                  if key not in resources[lang]:
                      continue
                  if package in resources[lang][key]:
                      flag = True
                      if key not in processor_list:
                          logger.debug(f"Found {key}: {package}.")
                          processor_list[key].append(package)
                      else:
                          logger.debug(
                              f"{key}: {package} is overwritten by "
                              f"{key}: {processors[key]}."
                          )
              if not flag:
                  logger.warning((f"Can not find package: {package}."))
      processor_list = [
          [
              key,
              [
                  ModelSpecification(
                      processor=key, package=value, dependencies=None
                  )
                  for value in plist
              ],
          ]
          for key, plist in processor_list.items()
      ]
      processor_list = sort_processors(processor_list)
      return processor_list
  
imports: from collections import defaultdict, namedtuple
  import errno
  import hashlib
  import json
  import logging
  import os
  from pathlib import Path
  import requests
  import shutil
  import tempfile
  import zipfile
  from tqdm.auto import tqdm
  from stanza.utils.helper_func import make_table
  from stanza.pipeline._constants import TOKENIZE, MWT, POS, LEMMA, DEPPARSE, NER, SENTIMENT
  from stanza.pipeline.registry import PIPELINE_NAMES, PROCESSOR_VARIANTS
  from stanza.resources.default_packages import PACKAGES
  from stanza._version import __resources_version__
label_desc: Use image node_id 11 for calling a global function with example usage: maintain_processor_list(resources, lang, package, processors, allow_pretrain, maybe_add_mwt) and returns: processor_list