code: def process_plugins(module_globals):
      _resolve_relative_paths(module_globals)
      # Set ENABLED_ and _TOGGLE_ variables. The ENABLED_* variables are read from
      # configuration and the _TOGGLE_* variables are initialized to empty lists to be
      # appended to from the extensions.
      for plugin_category in _plugin_categories:
          upper_category = plugin_category.upper()
          globals()["ENABLED_%s" % upper_category] = from_conf(
              "ENABLED_%s" % upper_category
          )
          globals()["_TOGGLE_%s" % upper_category] = []
  
          # Initialize the list of available plugins to what is available in Metaflow core
          globals()[
              _list_for_category(plugin_category)
          ] = _get_ext_plugins(module_globals, plugin_category)
  
      try:
          modules_to_import = get_modules("plugins")
          # This is like multiload_all but we load globals independently since we just care
          # about the TOGGLE and ENABLED values
          for m in modules_to_import:
              lazy_load_aliases(
                  alias_submodules(
                      m.module,
                      m.tl_package,
                      "plugins",
                      extra_indent=True,
                  )
              )
              for n, o in m.module.__dict__.items():
                  if (
                      n.startswith("TOGGLE_")
                      and n[7:].lower() in _plugin_categories
                  ):
                      # Extensions append to the TOGGLE list
                      globals()["_TOGGLE_%s" % n[7:]].extend(o)
                  elif (
                      n.startswith("ENABLED_")
                      and n[8:].lower() in _plugin_categories
                  ):
                      # Extensions override the ENABLED_ setting.
                      globals()[n] = o
  
              _resolve_relative_paths(m.module.__dict__)
              for plugin_category in _plugin_categories:
                  # Collect all the plugins present
                  globals()[_list_for_category(plugin_category)].extend(
                      _get_ext_plugins(
                          m.module.__dict__, plugin_category
                      )
                  )
      except Exception as e:
          _ext_debug(
              "\tWARNING: ignoring all plugins due to error during import: %s"
              % e
          )
          print(
              "WARNING: Plugins did not load -- ignoring all of them which may not "
              "be what you want: %s" % e
          )
          traceback.print_exc()
  
      # At this point, we have _all_<category>s populated with all the tuples
      # (name, module_class) from all the plugins in all the extensions (if any)
      # We build a dictionary taking the latest presence for each name (so plugins
      # override metaflow core)
      for plugin_category in _plugin_categories:
          upper_category = plugin_category.upper()
          d = globals()[_dict_for_category(plugin_category)] = {}
          for name, class_path in globals()[
              "_all_%ss" % plugin_category
          ]:
              _ext_debug(
                  "    Adding %s '%s' from '%s'"
                  % (plugin_category, name, class_path)
              )
              d[name] = class_path
  
          # Resolve all the ENABLED_* variables. The rules are the following:
          #  - if ENABLED_* is non None, it means it was either set directly by the user
          #    in a configuration file, on the command line or by an extension. In that case
          #    we honor those wishes and completely ignore the extensions' toggles.
          #  - if ENABLED_* is None, we populate it with everything included here and in
          #    all the extensions and use the TOGGLE_ list to produce the final list.
          # The rationale behind this is to support both a configuration option where the
          # plugins enabled are explicitly listed (typical in a lot of software) but also to
          # support a "configuration-less" version where the installation of the extensions
          # determines what is activated.
          if globals()["ENABLED_%s" % upper_category] is None:
              globals()["ENABLED_%s" % upper_category] = (
                  list(d) + globals()["_TOGGLE_%s" % upper_category]
              )
  
file_path: metaflow/metaflow/extension_support/plugins.py
imports: import importlib
  import traceback
  from metaflow.metaflow_config_funcs import from_conf
  from .None import _ext_debug, alias_submodules, get_modules, lazy_load_aliases
label_desc: Use image node_id 1 for calling a global function with example usage: process_plugins(module_globals) without return types