I have $\ell$ sets $S_1,S_2,\ldots,S_\ell$ where each set $S_k$ contains $n$ elements. Let $x_{ik}=1$ if and only if element $i$ is chosen from set $S_k$.
How to transform the following cardinality into a summation depending on $x_{ik}$?
$$f(O_1,O_2,\ldots,O_\ell)=\left|\bigcup_{k=1}^\ell O_k\right|,$$ where $O_k$ is a subset of elements chosen from $S_k$.
I found it as:
$$f(\mathbf{x})=\sum_{i=1}^{n}\prod_{k=1}^\ell x_{ik}.$$
First, we will calculate
$$g_i = \begin{cases} 1 \text{ if } i\in \displaystyle\bigcup_{k=1}^l O_k \\ 0 \text{ otherwise}\end{cases}$$
Notice that : $$ \prod_{k=1}^{l} 1-x_{ik} = \begin{cases} 0 \text{ if } i\in \bigcup_{k=1}^{l}O_k\\ 1\text{ otherwise}\end{cases}$$
So that :
$$ g_i = 1 - \prod_{k=1}^{l} (1-x_{ik})$$
Now, you can compute the desired function by summing the $g_i$'s :
$$ f(O_1, \ldots, O_l) = \sum_{i=1}^{+\infty} \left(1 - \prod_{k=1}^l (1- x_{ik})\right)$$
Notice that the previous sum is actually finite because $O_1\cup \ldots\cup O_l$ is finite.