def test_operation_to_choi(channel) -> None:
    """Verifies that cirq.operation_to_choi correctly computes the Choi matrix."""
    n_qubits = cirq.num_qubits(channel)
    actual = cirq.operation_to_choi(channel)
    expected = compute_choi(channel)
    assert np.isclose(np.trace(actual), 2**n_qubits)
    assert np.all(actual == expected)
Verifies that cirq.operation_to_choi correctly computes the Choi matrix.
cirq-core/cirq/qis/channels_test.py