Solution (source code)

= Solution

For $d$ variables, integrate over the product of $d$ unit circles:
$$
\langle f,g\rangle=\frac1{(2\pi)^d}
\int_{[0,2\pi]^d}f(e^{i\theta_1},\ldots,e^{i\theta_d})
\overline{g(e^{i\theta_1},\ldots,e^{i\theta_d})}\,d\theta_1\cdots d\theta_d.
$$
For <multi-indices> $\alpha,\beta\in\mathbb Z_{\ge0}^d$, applying one-variable <Fourier orthogonality> in each variable gives
$$
\langle z^\alpha,z^\beta\rangle=\prod_{j=1}^d\delta_{\alpha_j\beta_j}.
$$
If $f=\sum_\alpha a_\alpha z^\alpha$, its squared norm is $\sum_\alpha|a_\alpha|^2$, a finite sum. The form is therefore a positive definite <Hermitian form> and
$$
\boxed{\{z_1^{\alpha_1}\cdots z_d^{\alpha_d}:\alpha_j\ge0\}
\quad\text{is an orthonormal basis}.}
$$
This is the <monomial orthonormal basis on the unit torus>.