TITLE: Sum of squares and partitions
QUESTION [7 upvotes]: This is an off-shot from my previous post on MO.
Given an integer partition $\lambda=(\lambda_1,\dots,\lambda_{\ell(\lambda)})$ of $n$, denote $\ell(\lambda)$ to be the length of $\lambda$.
Let $r_2(n)$ denote the number of ways of expressing $n$ as a sum of two squares of integers, look it up on OEIS.
Here is perhaps a "new formulation" of $r_2(n)$:

QUESTION. Is this true? If it is, please either provide a reference or a proof.
  $$r_2(n)
=\sum_{\lambda\vdash n}(-1)^{n-\lambda_1}{\prod_{j=1}^{\ell(\lambda)}} \,4\,(\lambda_j-\lambda_{j+1})$$
  where $\lambda_{\ell(\lambda)+1}=0$ and the product excludes $\lambda_j=\lambda_{j+1}$.

Example. Take $n=4$. The solutions to $4=x^2+y^2$ are $(\pm2,0), (0,\pm2)$ and hence $r_2(4)=4$. On the other hand, $\lambda=(4,0), (3,1,0), (2,2,0), (2,1,1,0), (1,1,1,1,0)\vdash 4$ so that 
$$(-1)^{4-4}4\cdot4+(-1)^{4-3}4\cdot2\cdot4\cdot1+(-1)^{4-2}4\cdot2
+(-1)^{4-2}4\cdot1\cdot4\cdot1+(-1)^{4-1}4\cdot1=4.$$

REPLY [15 votes]: Start by checking that the following formal product can be expanded as a sum over partitions
$$\prod_{i\geq 1}\left(1+\sum_{r\geq 1}a_r(x_1x_2\cdots x_i)^r\right)=\sum_{\lambda}\left(\prod_{j\geq 1}a_{\lambda_j-\lambda_{j+1}}\right)\left(\prod_{j\geq 1}x_j^{\lambda_j}\right)$$
with the convention that $a_0=1$. The proof of this is really just a weighted version of the usual generating function for partitions.
If we set $x_1=t$ and $x_i=-t$ for $i\geq 2$, and all $a_r=4r$ for $r\geq 1$ then the right side becomes 
$$\sum_{n\geq 0} t^n\sum_{\lambda\vdash n}(-1)^{n-\lambda_1}{\prod_{j=1}^{\ell(\lambda)}} \,4\,(\lambda_j-\lambda_{j+1})$$
and the identity says that this is equal to the product
$$\prod_{i\geq 1} \left(1+\frac{4(-1)^{i-1}t^i}{(1-(-1)^{i-1}t^i)^2}\right)=\frac{(1+t)^2}{(1-t)^2}\cdot \frac{(1-t^2)^2}{(1+t^2)^2}\cdot \frac{(1+t^3)^2}{(1-t^3)^2}\cdots$$
$$=\prod_{k\geq 1}\frac{(1-t^{2k})^{10}}{(1-t^k)^4(1-t^{4k})^4}.$$
This last final expression is a well known product formula for $r_2(n)$:
$$\sum_nr_2(n)t^n=\frac{\eta(t^2)^{10}}{\eta(t)^4\,\eta(t^4)^4}, \qquad
\text{where $\eta(t)=t^{\frac1{24}}\prod_{k=1}^{\infty}(1-t^k)$ is the Dedekind eta function}.$$
So your identity follows.