code: def safe_import(self, name):
          
          module = None
          if name not in self._modules:
              self._modules[name] = importlib.import_module(name)
          module = self._modules[name]
          if not module:
              dist = next(iter(
                  dist for dist in self.base_working_set if dist.project_name == name
              ), None)
              if dist:
                  dist.activate()
              module = importlib.import_module(name)
          if name in sys.modules:
              try:
                  six.moves.reload_module(module)
                  six.moves.reload_module(sys.modules[name])
              except TypeError:
                  del sys.modules[name]
                  sys.modules[name] = self._modules[name]
          return module
docs: Helper utility for reimporting previously imported modules while inside the env