def import_file(file_path: str) -> ModuleType:
    """Finds and runs a python file as if were imported with an `import`
    statement.

    Args:
        file_path: The file to import.

    Returns: The imported module.

    Raises:
        ValueError: if unable to import the given file.
    """
    mod_name = 'cirq_doctest_module'
    # Find and create the module
    spec = importlib.util.spec_from_file_location(mod_name, file_path)
    if spec is None:
        raise ValueError(f'Unable to find module spec: mod_name={mod_name}, file_path={file_path}')
    mod = importlib.util.module_from_spec(spec)
    # Run the code in the module (but not with __name__ == '__main__')
    sys.modules[mod_name] = mod
    spec.loader.exec_module(mod)  # type: ignore
    mod = sys.modules[mod_name]
    del sys.modules[mod_name]
    return mod
Finds and runs a python file as if were imported with an `import`
    statement.

    Args:
        file_path: The file to import.

    Returns: The imported module.

    Raises:
        ValueError: if unable to import the given file.
    
dev_tools/docs/run_doctest.py