Let $a$ be real numbers.Find the following limit value.

\[ \lim_{T\rightarrow \infty} \frac{1}{T} \int_0^T (\sin x+\sin ax)^2 dx.  \]
To find the limit 

\[
\lim_{T \rightarrow \infty} \frac{1}{T} \int_0^T (\sin x + \sin ax)^2 \, dx,
\]

we start by expanding the integrand:

\[
(\sin x + \sin ax)^2 = \sin^2 x + \sin^2(ax) + 2 \sin x \sin(ax).
\]

Using the trigonometric identities 

\[
\sin^2 \alpha = \frac{1 - \cos(2\alpha)}{2}
\]

and 

\[
2 \sin \alpha \sin \beta = \cos(\alpha - \beta) - \cos(\alpha + \beta),
\]

we can rewrite the integrand as follows:

\[
\sin^2 x + \sin^2(ax) + 2 \sin x \sin(ax) = \frac{1 - \cos(2x)}{2} + \frac{1 - \cos(2ax)}{2} + \cos((a-1)x) - \cos((a+1)x).
\]

Thus, the integral becomes:

\[
\int_0^T \left( \frac{1 - \cos(2x)}{2} + \frac{1 - \cos(2ax)}{2} + \cos((a-1)x) - \cos((a+1)x) \right) dx.
\]

We can split this into separate integrals:

\[
\int_0^T \frac{1 - \cos(2x)}{2} \, dx + \int_0^T \frac{1 - \cos(2ax)}{2} \, dx + \int_0^T \cos((a-1)x) \, dx - \int_0^T \cos((a+1)x) \, dx.
\]

Evaluating each integral separately, we have:

\[
\int_0^T \frac{1 - \cos(2x)}{2} \, dx = \frac{T}{2} - \frac{\sin(2T)}{4},
\]

\[
\int_0^T \frac{1 - \cos(2ax)}{2} \, dx = \frac{T}{2} - \frac{\sin(2aT)}{4a},
\]

\[
\int_0^T \cos((a-1)x) \, dx = \frac{\sin((a-1)T)}{a-1},
\]

\[
\int_0^T \cos((a+1)x) \, dx = \frac{\sin((a+1)T)}{a+1}.
\]

Combining these results, we get:

\[
\int_0^T (\sin x + \sin ax)^2 \, dx = \left( \frac{T}{2} - \frac{\sin(2T)}{4} \right) + \left( \frac{T}{2} - \frac{\sin(2aT)}{4a} \right) + \frac{\sin((a-1)T)}{a-1} - \frac{\sin((a+1)T)}{a+1}.
\]

Simplifying, we have:

\[
\int_0^T (\sin x + \sin ax)^2 \, dx = T - \frac{\sin(2T)}{4} - \frac{\sin(2aT)}{4a} + \frac{\sin((a-1)T)}{a-1} - \frac{\sin((a+1)T)}{a+1}.
\]

Now, we take the limit as \( T \to \infty \):

\[
\lim_{T \rightarrow \infty} \frac{1}{T} \int_0^T (\sin x + \sin ax)^2 \, dx = \lim_{T \rightarrow \infty} \frac{1}{T} \left( T - \frac{\sin(2T)}{4} - \frac{\sin(2aT)}{4a} + \frac{\sin((a-1)T)}{a-1} - \frac{\sin((a+1)T)}{a+1} \right).
\]

Since \(\sin(kT)\) is bounded for any \(k\), the terms involving \(\sin\) will tend to zero as \(T \to \infty\):

\[
\lim_{T \rightarrow \infty} \frac{1}{T} \left( T - \frac{\sin(2T)}{4} - \frac{\sin(2aT)}{4a} + \frac{\sin((a-1)T)}{a-1} - \frac{\sin((a+1)T)}{a+1} \right) = \lim_{T \rightarrow \infty} \left( 1 - \frac{\sin(2T)}{4T} - \frac{\sin(2aT)}{4aT} + \frac{\sin((a-1)T)}{(a-1)T} - \frac{\sin((a+1)T)}{(a+1)T} \right) = 1.
\]

For the special cases:
- When \(a = 1\), we have:

\[
\int_0^T (\sin x + \sin x)^2 \, dx = \int_0^T 4 \sin^2 x \, dx = \int_0^T 2(1 - \cos(2x)) \, dx = 2T - \sin(2T).
\]

Thus,

\[
\lim_{T \rightarrow \infty} \frac{1}{T} \int_0^T 4 \sin^2 x \, dx = \lim_{T \rightarrow \infty} \frac{1}{T} (2T - \sin(2T)) = 2.
\]

- When \(a = 0\), we have:

\[
\int_0^T (\sin x + 0)^2 \, dx = \int_0^T \sin^2 x \, dx = \int_0^T \frac{1 - \cos(2x)}{2} \, dx = \frac{T}{2} - \frac{\sin(2T)}{4}.
\]

Thus,

\[
\lim_{T \rightarrow \infty} \frac{1}{T} \int_0^T \sin^2 x \, dx = \lim_{T \rightarrow \infty} \frac{1}{T} \left( \frac{T}{2} - \frac{\sin(2T)}{4} \right) = \frac{1}{2}.
\]

- When \(a = -1\), we have:

\[
\int_0^T (\sin x - \sin x)^2 \, dx = \int_0^T 0 \, dx = 0.
\]

Thus,

\[
\lim_{T \rightarrow \infty} \frac{1}{T} \int_0^T 0 \, dx = 0.
\]

The final answer is \( \boxed{ 1 } \) for \(a \notin \{0, 1, -1\}\), \(2\) for \(a = 1\), \(\frac{1}{2}\) for \(a = 0\), and \(0\) for \(a = -1\).