Use numpy's einsum to apply a multi-qubit channel.

def _apply_krauss_multi_qubit(krauss: Union[Tuple[Any], Sequence[Any]],
        args: 'ApplyChannelArgs') -> np.ndarray:
    """Use numpy's einsum to apply a multi-qubit channel."""
    for krauss_op in krauss:
        np.copyto(dst=args.target_tensor, src=args.auxiliary_buffer0)
        krauss_tensor = np.reshape(
                krauss_op.astype(args.target_tensor.dtype),
                (2,) * len(args.left_axes) * 2)
        linalg.targeted_left_multiply(
                krauss_tensor,
                args.target_tensor,
                args.left_axes,
                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.targeted_left_multiply(
                np.conjugate(krauss_tensor),
                args.auxiliary_buffer1,
                args.right_axes,
                out=args.target_tensor)
        args.out_buffer += args.target_tensor
    return args.out_buffer