async def async_download_all_titles(
    titles: List[str], dump_path_by_type_list: List[Dict[str, str]], title2qid: Dict[str, str],
) -> Tuple[bool, Dict[str, bool]]:
    """Try to download all Wikidata pages with the given titles. Download all or nothing, no partial downloads.

    Args:
        titles (List[str]):
        dump_path_by_type_list (List[Dict[str, str]]):

    Returns:
        bool: True if all Wikidata pages can be found and downloaded successfully, else False.
        Dict[str, bool]: The key is the tile str that has been accessed in this function call, the value is whether the
            page exists or not.
    """
    async with aiohttp.ClientSession() as session:
        tasks = [async_fetch_response(session, title, title2qid) for title in titles]
        results = await asyncio.gather(*tasks)

    responses: List[Tuple[str, aiohttp.ClientResponse]] = []
    title_valid: Dict[str, bool] = {}

    for title, response, is_valid in results:
        title_valid[title] = is_valid
        if not is_valid:
            return False, title_valid
        responses.append((title, response))

    download_tasks = []

    async with aiohttp.ClientSession() as session:
        for (title, response), dump_path_by_type in zip(responses, dump_path_by_type_list):
            qid = title2qid[title]
            for filetype, dump_path in dump_path_by_type.items():
                if filetype == "html":
                    obj = await ASYNC_FILE_TYPE_TO_GET_FUNCTION[filetype](response)
                elif filetype == "pdf":
                    obj = await ASYNC_FILE_TYPE_TO_GET_FUNCTION[filetype](session, qid)
                download_tasks.append(ASYNC_FILE_TYPE_TO_DUMP_FUNCTION[filetype](obj, dump_path))

        await asyncio.gather(*download_tasks)

    return True, title_valid
Try to download all Wikidata pages with the given titles. Download all or nothing, no partial downloads.

    Args:
        titles (List[str]):
        dump_path_by_type_list (List[Dict[str, str]]):

    Returns:
        bool: True if all Wikidata pages can be found and downloaded successfully, else False.
        Dict[str, bool]: The key is the tile str that has been accessed in this function call, the value is whether the
            page exists or not.
    
data_process/open_benchmarks/utils/wikidata.py