def __exit__(self, exc_type, exc_value, exc_tb):
        """Handle exiting from the WithOptionalImports context block.

        We should not get any exceptions here if dummies were produced by the
        overwritten __import__ but if an import of a module that exists failed
        becomes some component of that module did not, we will not be able to
        catch it to produce dummy and have to process the exception here in
        which case we add our informative message to the exception and re-raise
        it.
        """
        self.importing = False
        builtins.__import__ = self.imp

        if exc_value is None:
            return

        if isinstance(exc_value, ModuleNotFoundError):
            if exc_value.msg.startswith(self.messages.module_not_found):
                # Don't add more to the message if it already includes our instructions.
                raise exc_value

            raise ModuleNotFoundError(
                self.messages.module_not_found
            ) from exc_value

        elif isinstance(exc_value, ImportError):
            if exc_value.msg.startswith(self.messages.import_error):
                # Don't add more to the message if it already includes our instructions.
                raise exc_value

            raise ImportError(self.messages.import_error) from exc_value

        # Exception will be propagated unless we return True so we don't return it.
Handle exiting from the WithOptionalImports context block.

        We should not get any exceptions here if dummies were produced by the
        overwritten __import__ but if an import of a module that exists failed
        becomes some component of that module did not, we will not be able to
        catch it to produce dummy and have to process the exception here in
        which case we add our informative message to the exception and re-raise
        it.
        
src/core/trulens/core/utils/imports.py