code: def has_binding_new(api):
      """Safely check for PyQt4/5, PySide or PySide2, without importing submodules
  
      Supports Python >= 3.4
  
          Parameters
          ----------
          api : str [ 'pyqtv1' | 'pyqt' | 'pyqt5' | 'pyside' | 'pyside2' | 'pyqtdefault']
               Which module to check for
  
          Returns
          -------
          True if the relevant module appears to be importable
      """
      module_name = api_to_module[api]
      from importlib.util import find_spec
  
      required = ["QtCore", "QtGui", "QtSvg"]
      if api in (QT_API_PYQT5, QT_API_PYSIDE2):
          # QT5 requires QtWidgets too
          required.append("QtWidgets")
  
      for submod in required:
          try:
              spec = find_spec("%s.%s" % (module_name, submod))
          except ImportError:
              # Package (e.g. PyQt5) not found
              return False
          else:
              if spec is None:
                  # Submodule (e.g. PyQt5.QtCore) not found
                  return False
  
      if api == QT_API_PYSIDE:
          # We can also safely check PySide version
          import PySide
  
          return check_version(PySide.__version__, "1.0.3")
  
      return True
  
imports: import sys
  import types
  from functools import partial
  from IPython.utils.version import check_version
label_desc: Use image node_id 4 for calling a global function with example usage: has_binding_new(api) and returns: True, check_version, False, False