def extract_dataset_summary_and_mapping(scenario_list, dataset_name, dataset_version):
    """Extract the dataset summary and mapping for dataset_summary.pkl and dataset_mapping.pkl.

    Args:
        scenario_list: A list of Scenario Description objects.

    Returns:
        Summary dict, mapping dict, scenario dict
    """
    summary = {}
    mapping = {}
    scenario_dict = {}
    for sd_scenario in scenario_list:
        scenario_id = sd_scenario[SD.ID]
        export_file_name = SD.get_export_file_name(dataset_name, dataset_version, scenario_id)

        sd_scenario = SD(sd_scenario)
        if hasattr(SD, "update_summaries"):
            SD.update_summaries(sd_scenario)
        else:
            raise ValueError("Please update MetaDrive to latest version.")

        # update summary/mapping dict
        if export_file_name in summary:
            logger.warning("Scenario {} already exists and will be overwritten!".format(export_file_name))
        summary[export_file_name] = copy.deepcopy(sd_scenario[SD.METADATA])
        mapping[export_file_name] = ""  # in the same dir

        # sanity check
        sd_scenario = sd_scenario.to_dict()
        SD.sanity_check(sd_scenario, check_self_type=True)

        scenario_dict[export_file_name] = sd_scenario

    return summary, mapping, scenario_dict
Extract the dataset summary and mapping for dataset_summary.pkl and dataset_mapping.pkl.

    Args:
        scenario_list: A list of Scenario Description objects.

    Returns:
        Summary dict, mapping dict, scenario dict
    
metadrive/scenario/utils.py