code: def _get_external_card_packages():
      """
      Safely extract all external card modules
      Returns:
          `list` of `ModuleType`
      """
      import importlib
  
      # Caching card related modules.
      global _CARD_MODULES
      if len(_CARD_MODULES) > 0:
          return _CARD_MODULES
      for m in get_modules("plugins.cards"):
          card_packages = []
          # condition checks if it is not a namespace package or is a regular package.
          if getattr(m.module, "__file__", None):
              # This supports the following cases
              # - a namespace package support with mfextinit_X.py
              # - a regular package support
              card_packages.append(m.module)
          else:
              # This is to support current system where you have a namespace package and then sub packages
              # that have __init__.py
              for _, card_mod, ispkg_c in iter_namespace(m.module):
                  # Iterate submodules of metaflow_extensions.X.plugins.cards
                  # For example metaflow_extensions.X.plugins.cards.monitoring
                  try:
                      if not ispkg_c:
                          continue
                      cm = importlib.import_module(card_mod)
                      _ext_debug("Importing card package %s" % card_mod)
                      card_packages.append(cm)
                  except Exception as e:
                      _ext_debug(
                          "External Card Module Import Exception \n\n %s \n\n %s"
                          % (str(e), traceback.format_exc())
                      )
  
          _CARD_MODULES.extend(card_packages)
      return _CARD_MODULES
  
imports: import os
  import traceback
  from .card import MetaflowCard, MetaflowCardComponent
  from metaflow.extension_support import get_modules, EXT_PKG, _ext_debug
label_desc: Use image node_id 2 for calling a global function with example usage: _get_external_card_packages() and returns: _CARD_MODULES, _CARD_MODULES