def extract_dual_value(sdp, monomial, blocks=None):
if sdp.status == "<STR_LIT>":<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>if blocks is None:<EOL><INDENT>blocks = [i for i, _ in enumerate(sdp.block_struct)]<EOL><DEDENT>if is_number_type(monomial):<EOL><INDENT>index = <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>index = sdp.monomial_index[monomial]<EOL><DEDENT>row_offsets = [<NUM_LIT:0>]<EOL>cumulative_sum = <NUM_LIT:0><EOL>for block_size in sdp.block_struct:<EOL><INDENT>cumulative_sum += block_size ** <NUM_LIT:2><EOL>row_offsets.append(cumulative_sum)<EOL><DEDENT>result = <NUM_LIT:0><EOL>for row in range(len(sdp.F.rows)):<EOL><INDENT>if len(sdp.F.rows[row]) > <NUM_LIT:0>:<EOL><INDENT>col_index = <NUM_LIT:0><EOL>for k in sdp.F.rows[row]:<EOL><INDENT>if k != index:<EOL><INDENT>continue<EOL><DEDENT>value = sdp.F.data[row][col_index]<EOL>col_index += <NUM_LIT:1><EOL>block_index, i, j = convert_row_to_sdpa_index(<EOL>sdp.block_struct, row_offsets, row)<EOL>if block_index in blocks:<EOL><INDENT>result += -value*sdp.y_mat[block_index][i][j]<EOL><DEDENT><DEDENT><DEDENT><DEDENT>return result<EOL>
Given a solution of the dual problem and a monomial, it returns the
    inner product of the corresponding coefficient matrix and the dual
    solution. It can be restricted to certain blocks.

    :param sdp: The SDP relaxation.
    :type sdp: :class:`ncpol2sdpa.sdp`.
    :param monomial: The monomial for which the value is requested.
    :type monomial: :class:`sympy.core.exp.Expr`.
    :param monomial: The monomial for which the value is requested.
    :type monomial: :class:`sympy.core.exp.Expr`.
    :param blocks: Optional parameter to specify the blocks to be included.
    :type blocks: list of `int`.
    :returns: The value of the monomial in the solved relaxation.
    :rtype: float.