def _apply_kraus_single_qubit(
    kraus: tuple[Any] | Sequence[Any], args: ApplyChannelArgs
) -> np.ndarray:
    """Use slicing to apply single qubit channel.  Only for two-level qubits."""
    zero_left = linalg.slice_for_qubits_equal_to(args.left_axes, 0)
    one_left = linalg.slice_for_qubits_equal_to(args.left_axes, 1)
    zero_right = linalg.slice_for_qubits_equal_to(args.right_axes, 0)
    one_right = linalg.slice_for_qubits_equal_to(args.right_axes, 1)
    for kraus_op in kraus:
        np.copyto(dst=args.target_tensor, src=args.auxiliary_buffer0)
        linalg.apply_matrix_to_slices(
            args.target_tensor, kraus_op, [zero_left, one_left], out=args.auxiliary_buffer1
        )
        # No need to transpose as we are acting on the tensor
        # representation of matrix, so transpose is done for us.
        linalg.apply_matrix_to_slices(
            args.auxiliary_buffer1,
            np.conjugate(kraus_op),
            [zero_right, one_right],
            out=args.target_tensor,
        )
        args.out_buffer += args.target_tensor
    return args.out_buffer
Use slicing to apply single qubit channel.  Only for two-level qubits.
cirq-core/cirq/protocols/apply_channel_protocol.py