def read_dataset_summary(file_folder, check_file_existence=True):
    """
    Read the `dataset_summary.pkl` and return the metadata of each scenario in this dataset.

    This function supports two methods to load pickle files. The first is the old method where we store pickle files in
    0.pkl, 1.pkl, .... The second is the new method which use a summary file to record important metadata of
    each scenario.

    Args:
        file_folder: the path to the root folder of your dataset.
        check_file_existence: check if all scenarios registered in the summary file exist.

    Returns:
        A tuple of three elements:
        1) the summary dict mapping from scenario ID to its metadata,
        2) the list of all scenarios IDs, and
        3) a dict mapping from scenario IDs to the folder that hosts their files.
    """
    file_folder = pathlib.Path(file_folder)
    summary_file = file_folder / SD.DATASET.SUMMARY_FILE
    mapping_file = file_folder / SD.DATASET.MAPPING_FILE
    if os.path.isfile(summary_file):
        with open(summary_file, "rb") as f:
            summary_dict = pickle.load(f)

    else:
        logger.warning(f"Summary file is not found at {summary_file}! Generate a dummy one.")

        # === The following is deprecated ===
        # Create a fake one
        files = []
        for file in os.listdir(file_folder):
            if SD.is_scenario_file(os.path.basename(file)):
                files.append(file)
        summary_dict = {f: {} for f in files}

    mapping = None
    if os.path.exists(mapping_file):
        with open(mapping_file, "rb") as f:
            mapping = pickle.load(f)

    if not mapping:
        # Create a fake one
        mapping = {k: "" for k in summary_dict}

    if check_file_existence:
        for file in summary_dict:
            assert file in mapping, "FileName in mapping mismatch with summary"
            assert SD.is_scenario_file(file), "File:{} is not sd scenario file".format(file)
            file_path = file_folder / mapping[file] / file
            assert os.path.exists(file_path), "Can not find file: {}".format(file_path)

    return summary_dict, list(summary_dict.keys()), mapping

    Read the `dataset_summary.pkl` and return the metadata of each scenario in this dataset.

    This function supports two methods to load pickle files. The first is the old method where we store pickle files in
    0.pkl, 1.pkl, .... The second is the new method which use a summary file to record important metadata of
    each scenario.

    Args:
        file_folder: the path to the root folder of your dataset.
        check_file_existence: check if all scenarios registered in the summary file exist.

    Returns:
        A tuple of three elements:
        1) the summary dict mapping from scenario ID to its metadata,
        2) the list of all scenarios IDs, and
        3) a dict mapping from scenario IDs to the folder that hosts their files.
    
metadrive/scenario/utils.py