Total variation distance on product space Let $X$ be a measurable space. Given probability measures $p$ and $q$ on $X$, define their total variation distance as
$$
d(p,q) = \sup_f \Big| \int f \, dp - \int f \, dq \Big| ,
$$
where $f$ varies over measurable functions $X \to [0,1]$.
If $Y$ is also a measurable space, let now $p$ and $q$ be measures on the product $X \times Y$. Again,
$$
d(p,q) = \sup_f \Big| \int f \, dp - \int f \, dq \Big| ,
$$
where now $f$ varies over measurable functions $X \times Y\to [0,1]$.
However, can we equivalently test the distance with functions in the form $f(x,y)=g(x)h(y)$?
That is, can we write
$$
d(p,q) = \sup_{g,h} \Big| \int gh \, dp - \int gh \, dq \Big| ,
$$
where $g: X \to [0,1]$ and $h: Y \to [0,1]$?
 A: We can construct a counterexample:
Take $X=Y=[0,1]$, $\tilde f(x,y) = \begin{Bmatrix}1, x\leq y \\ -1 , x>y\end{Bmatrix}$,
$p(A)=\lambda_2(A \cap \{x\leq y\})$, $q(A)=\lambda_2(A \cap \{x\ > y\})$.
Now $$\sup_{f}|\int f \; dp - \int f \; dq|$$ is $1$ and is achieved with $f = \tilde f$.
Now suppose we have $g_n$ and $h_n$ such that $$\sup_{f}|\int g_nh_n\; dp - \int g_nh_n \;dq| = \sup_{f}|\int g_nh_n\tilde f \; d\lambda_2| \rightarrow 1$$
The function under the last integral is bounded by $|g_nh_n\tilde f|$, which is in turn bounded by $1$.
For the integral to approach $1$ the $|g_nh_n\tilde f|$ must also approach $1$ almost everywhere. Furthermore $\lambda_2(g_nh_n\tilde f > 0)$ or $\lambda_2(g_nh_n\tilde f < 0)$ must tend to $1$.
In other words, either $g_nh_n\tilde f\rightarrow 1$ or $g_nh_n\tilde f\rightarrow -1$ almost everywhere.
However, that is impossible.
To convince yourself of this consider the sets
$$G_+ = \{x|g_n(x) \geq 0\}$$$$G_- = \{x|g_n(x) \leq 0\}$$
$$H_+ = \{y|h_n(y) \geq 0\}$$$$H_- = \{y|h_n(y) \leq 0\}$$
and show that both $\{g_nh_n\tilde f \geq 0\}$ and $\{g_nh_n\tilde f \leq 0\}$ have positive measure.
[![this should give you the idea why that is][1]][1]
[1]: https://i.stack.imgur.com/7EkSJ.png
A: Let $X=Y=\{0,1\}$. Suppose $p$ is uniform on the two points $\{(0,0),(1,1)\}$ and $q$
is uniform on $\{(0,1),(1,0)\}$.
The function $F:X \times Y \to [0,1]$ that is the indicator of  $\{(0,0),(1,1)\}$ shows  that $$d(p,q)=1\,.$$ However, given $g:X   \to [0,1]$ and $h: Y \to [0,1]$, we have
\begin{eqnarray} \Bigl|\int gh \,dp-\int gh \, dq\Bigr|  &=&\frac12\Bigl|g(0)h(0)+g(1)h(1)-g(0)h(1)-g(1)h(0)\Bigr|\\ &=&\frac12|g(0)-g(1)| \cdot |h(0)-h(1)| \le 1/2.
\end{eqnarray}
