def _save_base_module(self):
        """
            Remember state of the last of existing modules
            The last of the sequence of existing modules
            is the only one we will change. So we must
            remember it's state in order to restore it
            afterwards.
        """

        try:
            # save last of the existing modules
            self.base_module = sys.modules[self.known_path]
        except __HOLE__:
            self.base_module = None

        # save `__all__` attribute of the base_module
        self.base_all = []
        if hasattr(self.base_module, '__all__'):
            self.base_all = list(self.base_module.__all__)
        if self.base_module:
            # change base_module's `__all__` attribute
            # to include the first module of the sequence
            self.base_module.__all__ = self.base_all + [self.elements[0]]
            setattr(self.base_module, self.elements[0], self.modules[0])
dataset/ETHPy150Open menpo/menpo/menpo/testing.py/surrogate._save_base_module