human
Complete this python program:
def _emit_post_update_statements(base_mapper, uowtransaction, cached_connections, mapper, table, update):
assistant
#Here is the Python code you requested.

    """Emit UPDATE statements corresponding to value lists collected
    by _collect_post_update_commands().
    """
    needs_version_id = ((mapper.version_id_col is not None) and (mapper.version_id_col in mapper._cols_by_table[table]))
    def update_stmt():
        clause = sql.and_()
        for col in mapper._pks_by_table[table]:
            clause.clauses.append((col == sql.bindparam(col._label, type_=col.type)))
        if needs_version_id:
            clause.clauses.append((mapper.version_id_col == sql.bindparam(mapper.version_id_col._label, type_=mapper.version_id_col.type)))
        stmt = table.update(clause)
        if (mapper.version_id_col is not None):
            stmt = stmt.return_defaults(mapper.version_id_col)
        return stmt
    statement = base_mapper._memo(('post_update', table), update_stmt)
    for (key, records) in groupby(update, (lambda rec: (rec[3], set(rec[4])))):
        rows = 0
        records = list(records)
        connection = key[0]
        assert_singlerow = connection.dialect.supports_sane_rowcount
        assert_multirow = (assert_singlerow and connection.dialect.supports_sane_multi_rowcount)
        allow_multirow = ((not needs_version_id) or assert_multirow)
        if (not allow_multirow):
            check_rowcount = assert_singlerow
            for (state, state_dict, mapper_rec, connection, params) in records:
                c = cached_connections[connection].execute(statement, params)
                _postfetch_post_update(mapper_rec, uowtransaction, table, state, state_dict, c, c.context.compiled_parameters[0])
                rows += c.rowcount
        else:
            multiparams = [params for (state, state_dict, mapper_rec, conn, params) in records]
            check_rowcount = (assert_multirow or (assert_singlerow and (len(multiparams) == 1)))
            c = cached_connections[connection].execute(statement, multiparams)
            rows += c.rowcount
            for (state, state_dict, mapper_rec, connection, params) in records:
                _postfetch_post_update(mapper_rec, uowtransaction, table, state, state_dict, c, c.context.compiled_parameters[0])
        if...