def _kak_decomposition_to_operations(
    q0: cirq.Qid, q1: cirq.Qid, kak: linalg.KakDecomposition, atol: float = 1e-8
) -> list[ops.Operation]:
    """Assumes that the decomposition is canonical."""
    b0, b1 = kak.single_qubit_operations_before
    pre = [_do_single_on(b0, q0, atol), _do_single_on(b1, q1, atol)]
    a0, a1 = kak.single_qubit_operations_after
    post = [_do_single_on(a0, q0, atol), _do_single_on(a1, q1, atol)]

    return list(
        cast(
            Iterable[ops.Operation],
            ops.flatten_op_tree(
                [pre, _non_local_part(q0, q1, kak.interaction_coefficients, atol), post]
            ),
        )
    )
Assumes that the decomposition is canonical.
cirq-core/cirq/transformers/analytical_decompositions/two_qubit_to_ms.py