The polynomial ring $\mathbb{C}[x_1,\ldots,x_r]$ is a unique factorization domain. This means that for a polynomial $P$ you can write it as $P=P_1^{\alpha_1}\ldots P_r^{\alpha_r}$, with $P_i$ irreducible. Of course, we don't know yet this factorization otherwise we would know it is a square.
Let's take a variable $x$ that appears in the polynomial. I would take the variable which appears with smallest maximal degree. You can write $P$ as a polynomial in $x$ with coefficients that are polynomials in the other variables. Take derivative $P_x$ with respect to $x$. Compute the greatest common divisor $D$ of $P$ and $P_x$. There are algorithms for that. Search for the keyword resultant and/or discriminant. Divide $P$ by $D$. That should gives us $R=P_1\ldots P_r$.
If $P$ is a square it should be divisible by $R^2$. Dividing $P/R^2$ subtracts $2$ from each of the $\alpha_i$.
Repeating the above procedure with $P/R^2$ instead of $P$ successively, eventually gets you to the polynomial $1$ if and only if $P$ was a square. If you ever get that the $P$ you are working with in one of the iterations is not divisible by the corresponding $R^2$ then it wasn't a square.