What's the difference between p(Z, X=x) and p(Z|X=x)? I'm trying to understand variational inference, and I've found resources that mention $p(Z, X=x)$, where $Z$ is a latent random variable and $X$ is the observed random variable. (Here is one such example)
Is there a difference between $p(Z, X=x)$ and $p(Z|X=x)$? Let's consider a simple example: $X$ is a random variable of MNIST handwritten digit images, and $Z$ is the random variable for the actual digit class (i.e. if x is a picture of a hand drawn 7, z is 7)

With conditioning, you reduce the space of possible outcomes, which can change the probabilities.
Imagine there are precisely two images $x_1$ and $x_2$ with the following probabilities:




Z=
0
1
2
3
4
5
6
7
8
9




X=x1
0
0.05
0
0
0
0
0
0.45
0
0


X=x2
0
0
0
0
0
0.25
0.25
0
0
0




The probabilities over the complete table add up to one, as they should. In this case, I have chosen both images to be of equal probability, i.e. the row sums are both $0.5$, so $p(X = x_1) = p(X = x_2) = 0.5$.
Now, the table says $p(Z=7, X = x_1) = 0.45$. But if we condition on $X = x_1$, i.e. we consider $p(Z|X = x_1)$, we exclude all possibilities from the second row. But the sum of all the probabilities must still be equal to one, so we have to normalize the first row, which is done by dividing each cell in the first row by the probability of the first row, i.e. by $0.5$. That gives:




Z=
0
1
2
3
4
5
6
7
8
9




X=x1
0
0.1
0
0
0
0
0
0.9
0
0




So, this table says that $p(Z=7|X=x_1) = 0.9$. In formulas, that normalization is just the definition of conditional probabilities:
$$
p(Z=7|X = x_1) = \frac{p(Z=7, X=x_1)}{p(X=x_1)} = \frac{0.45}{0.5} = 0.9.
$$
