def _discover_import(self, prefer=None):
available_packages = self.packages<EOL>if isinstance(prefer, str):<EOL><INDENT>available_packages = (prefer,)<EOL><DEDENT>for module_name in available_packages:<EOL><INDENT>spec = importlib.util.find_spec(module_name)<EOL>if spec is not None:<EOL><INDENT>importlib.import_module(module_name)<EOL>imported_hook = getattr(self, f"<STR_LIT>", None)<EOL>if callable(imported_hook):<EOL><INDENT>imported_hook(sys.modules[module_name])<EOL><DEDENT>return module_name<EOL><DEDENT><DEDENT>raise ModuleNotFoundError(f"<STR_LIT>")<EOL>
Discovers and imports the best available module from ``packages``.

        :raises ModuleNotFoundError: If no module is available
        :return: The name of the module to use
        :rtype: str