def filter_and_save(raw, symbol_ids, destination_path):
    """
    Parameters
    ----------
    raw : dict
        with key 'handwriting_datasets'
    symbol_ids : dict
        Maps LaTeX to write-math.com id
    destination_path : str
        Path where the filtered dict 'raw' will be saved
    """
    logging.info('Start filtering...')
    new_hw_ds = []
    for el in raw['handwriting_datasets']:
        if el['formula_id'] in symbol_ids:
            el['formula_id'] = symbol_ids[el['formula_id']]
            el['handwriting'].formula_id = symbol_ids[el['formula_id']]
            new_hw_ds.append(el)
    raw['handwriting_datasets'] = new_hw_ds

    # pickle
    logging.info('Start dumping %i recordings...', len(new_hw_ds))
    pickle.dump(raw, open(destination_path, "wb"), 2)
Parameters
    ----------
    raw : dict
        with key 'handwriting_datasets'
    symbol_ids : dict
        Maps LaTeX to write-math.com id
    destination_path : str
        Path where the filtered dict 'raw' will be saved