The cardinality of a finite set $X$ is the number of its elements. Once you know that, you would define the groupoid cardinality of a $\infty$-groupoid $X$ as the quantity $$\lvert X\rvert := \sum_{[x] \in \pi_0 X}\prod_{n=1}^\infty \lvert\pi_n(X,x)\rvert^{(-1)^n} = \sum_{[x] \in \pi_0 X}\frac{\lvert\pi_2 (X,x)\rvert \cdot \lvert\pi_4 (X,x)\rvert \dotsm}{\lvert\pi_1(X,x)\rvert \cdot \lvert\pi_3(X,x)\rvert \dotsm}$$ when it exists. At least, I wish I could make that conceptual leap. What are some natural ways to understand this definition of groupoid cardinality? This has also been called the total homotopy order of $X$ (see e.g. the reference below) and the homotopy cardinality of $X$.
If $X$ is an ordinary groupoid, then $$\lvert X\rvert = \sum_{[x] \in \pi_0 X}\frac{1}{\lvert\operatorname{Aut}(x)\rvert}.$$ This I understand probabilistically: if $X$ is a finite set with an equivalence relation $\sim$, a natural probability measure on $X/{\sim}$ weighs an orbit $[x]$ based on how likely it is that $y\in X$ is in $[x]$. Then, taking the uniform distribution on $X$ on considering this weighting, if you want to measure the "size" of $X/{\sim}$ by weightedly counting elements, you recover the formula in this case: $\lvert X/{\sim}\rvert = \sum_{[x] \in X/{\sim}}\frac{1}{\lvert[x]\rvert}$. This line of reasoning brings you, for example, to the statement that among finite sets, a random finite set $S$ should occur with probability $(e\lvert S\rvert!)^{-1}$, c.f. Qiaochu Yuan's answer to Cohen-Lenstra Heuristics reference.
Probability here is not being used in an essential way, it's just a convenient language to talk about the "natural size" of objects. Although I would be happy to hear a probabilistic interpretation of the general definition.
I know this is also related to QM, QFTs, …. But it is not clear to me how. It is defined, for instance, in Quinn's "Lectures on axiomatic topological quantum field theory" in Eq. (4.4) on pp. 340 within Freed and Uhlenbeck's Geometry and Quantum Field Theory (1991). There's a very brief discussion there, but it builds on previous discussion I've not read. I would also like to hear a derivation coming from this perspective.