def remove_invalid_records_from_split_dictionary(split_dictionary: dict, records: dict) -> dict:
    """ Removes records that exist in split_dictionary but not in records.
    Can be useful if you previously had a video in your project and used that to make a train / val / test split,
    but later deleted it.
    """
    valid_records = {}
    record_keys = list(records.keys())
    for split in ['train', 'val', 'test']:
        valid_records[split] = {}
        splitfiles = split_dictionary[split]
        for i, key in enumerate(record_keys):
            if key in splitfiles:
                valid_records[split][key] = records[key]
    return valid_records