code: def clear_modules():
          
          # next lets force remove any inasafe related modules
          modules = []
          for module in sys.modules:
              if 'inasafe' in module:
                  # Check if it is really one of our modules i.e. exists in the
                  # plugin directory
                  tokens = module.split('.')
                  path = ''
                  for myToken in tokens:
                      path += os.path.sep + myToken
                  parent = os.path.abspath(os.path.join(
                      __file__, os.path.pardir, os.path.pardir))
                  full_path = os.path.join(parent, path + '.py')
                  if os.path.exists(os.path.abspath(full_path)):
                      LOGGER.debug('Removing: %s' % module)
                      modules.append(module)
          for module in modules:
              del (sys.modules[module])
          for module in sys.modules:
              if 'inasafe' in module:
                  print(module)
  
          # Lets also clean up all the path additions that were made
          package_path = os.path.abspath(os.path.join(
              os.path.dirname(__file__), os.path.pardir))
          LOGGER.debug('Path to remove: %s' % package_path)
          # We use a list comprehension to ensure duplicate entries are removed
          LOGGER.debug(sys.path)
          sys.path = [y for y in sys.path if package_path not in y]
          LOGGER.debug(sys.path)
docs: Unload inasafe functions and try to return QGIS to before InaSAFE.
  
          .. todo:: I think this function can be removed. TS.