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

    """Emit UPDATE statements corresponding to value lists collected
    by _collect_update_commands().
    """
    needs_version_id = ((mapper.version_id_col is not None) and table.c.contains_column(mapper.version_id_col))
    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.base_mapper.eager_defaults:
            stmt = stmt.return_defaults()
        elif (mapper.version_id_col is not None):
            stmt = stmt.return_defaults(mapper.version_id_col)
        return stmt
    statement = base_mapper._memo(('update', table), update_stmt)
    rows = 0
    for (state, state_dict, params, mapper, connection, value_params) in update:
        if value_params:
            c = connection.execute(statement.values(value_params), params)
        else:
            c = cached_connections[connection].execute(statement, params)
        _postfetch(mapper, uowtransaction, table, state, state_dict, c, c.context.compiled_parameters[0], value_params)
        rows += c.rowcount
    if connection.dialect.supports_sane_rowcount:
        if (rows != len(update)):
            raise orm_exc.StaleDataError(("UPDATE    statement    on    table    '%s'    expected    to    update    %d    row(s);    %d    were    matched." % (table.description, len(update), rows)))
    elif needs_version_id:
        util.warn(('Dialect    %s    does    not    support    updated    rowcount    -    versioning    cannot    be    verified.' % c.dialect.dialect_description), stacklevel=12)