def _write_pickle(filepath, data, kwargs):
    """See documentation of mpu.io.write."""
    if 'protocol' not in kwargs:
        kwargs['protocol'] = pickle.HIGHEST_PROTOCOL
    with open(filepath, 'wb') as handle:
        pickle.dump(data, handle, **kwargs)
    return data