def _embed_initial_state(initial_state, embedding, qubits):
    """Embed the states provided by the initial_state parameter used for reverse annealing.

    Args:

        initial_state (list of lists): Logical initial state as it would be passed to SAPI for reverse annealing.

        embedding (dict): The embedding used to embed the initial state.  Maps logical indices to chains.

        qubits (list): A list of qubits on the target topology.


    Returns (list of lists):

        The initial_state, embedded according to the provided embedding.
    """

    # Initialize by setting all qubits to 1 (these will be overwritten for active qubits).
    embedded_state = {q: 1 for q in qubits}

    for logical_idx, logical_value in initial_state:  # Iterate through the logical qubit, state pairs.
        for embedded_idx in embedding[logical_idx]:  # For each embedded qubit in the corresponding chain...
            embedded_state[embedded_idx] = int(logical_value)  # make the embedded state equal to the logical state.

    # Convert dictionary to a list of lists.
    embedded_state_list_of_lists = [[q_emb, embedded_state[q_emb]] for q_emb in sorted(embedded_state.keys())]

    return embedded_state_list_of_lists