def find_used_modules(modules, text):
    """
    Given a list of modules, return the set of all those imported in text
    """
    used = set()
    for line in text.splitlines():
        for mod in modules:
            if 'import' in line and mod in line:
                used.add(mod)
    return used