def doc_value_wrapper(doc_cls, value_cls):
    #from corehq.apps.users.models import CouchUser
    def wrapper(row):

        data = row.get('value')
        docid = row.get('id')
        doc = row.get('doc')

        data['_id'] = docid
        if 'rev' in data:
            data['_rev'] = data.pop('rev')
        value_cls._allow_dynamic_properties = True
        doc_cls._allow_dynamic_properties = True
        value_inst = value_cls.wrap(data)
        doc_inst = doc_cls.wrap(doc)
        return doc_inst, value_inst
    return wrapper
Returns:
dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/users/util.py/doc_value_wrapper--crossover with--dataset/ETHPy150Open meraki-analytics/cassiopeia/cassiopeia/type/core/stats.py/AggregatedStats.bot_games