def get_titles_to_download(sample: dict) -> Dict[str, List[str]]:
    """Download only the supporting facts related documents if exist, else retrieval contexts related documents."""
    metadata = sample["metadata"]
    titles_by_type = {source_type: set() for source_type in SOURCE_TYPES_TO_DOWNLOAD}
    if "supporting_facts" in metadata:
        for supporting_fact in metadata["supporting_facts"]:
            titles_by_type[supporting_fact["type"]].add(supporting_fact["title"])
    else:
        for retrieval_context in metadata["retrieval_contexts"]:
            titles_by_type[retrieval_context["type"]].add(retrieval_context["title"])

    return {key: list(value_set) for key, value_set in titles_by_type.items()}
Download only the supporting facts related documents if exist, else retrieval contexts related documents.
data_process/open_benchmarks/sample_dataset.py