Gauge invariance of loop Diagrams Say we have a gauge-fixed QED Lagrangian: $$\mathcal{L} =  - \frac{1}{4}{F}_{\mu\nu}F^{\mu\nu}+ \frac{1}{2a}\left(\partial_\mu A^\mu\right)^2+\bar\psi_1(i\gamma^\mu D_\mu - m_1)\psi_1.$$
My question is how can we check the gauge invariance of loop diagrams. I've seen in https://arxiv.org/abs/hep-ph/0508242 (page 46) that they use an argument

"The photon self-energy at two loops is gauge-invariant, because there are no off-shell charged external particles. Therefore, we may use any gauge; the calculation in the Feynman gauge $a = 1$ is easiest."

But I am not sure I understood the argument: What do they mean by off-shell charged external particles?
 A: This follows from the diagrammatical Ward identity. For a proof I can recommend Peskin 7.4. To get a good understanding you should read this, I will just state the theorem.
Let us consider QED. One can state the diagrammatic Ward identity essentially as follows:
For any given diagram with on-shell fermion legs (we do not need external photons to be on-shell!), i.e. the fermion legs are treated according to the LSZ formula, sum over all possible insertions of an external photon into this diagram, we denote this by
$$
\sum_{\text{insertions}}\epsilon^{\mu}(k) \mathcal{D}_{\mu},
$$
where $\mathcal{D}_{\mu}$ is the resulting diagram of a given insertion with the photon leg amputated. Then we have
$$
\sum_{\text{insertions}} k^{\mu} \mathcal{D}_{\mu} = 0.
$$
Now how does this imply gauge invariance? Consider some arbitrary $S$-matrix element at some given order, denote $\mathcal{M}$. All the diagrams contributing to this will have the same number of internal photons, say $m$. Then we can write
$$
\mathcal{M}= \int d^4k_1...\int d^4k_m~\Pi^{\mu_1 \nu_1}(k_1)...\Pi^{\mu_m \nu_m}(k_m) \mathcal{M}_{\mu_1 \nu_1... \mu_m \nu_m}.
$$
Now changing gauge corresponds to the replacement
$$
\Pi^{\mu_j \nu_j}(k_j) \rightarrow \Pi^{\mu_j \nu_j}(k_j) + \xi k_j^{\mu_j} k_j^{\nu_j}
$$
But recall that $\mathcal{M}$ contains exactly all the diagrams contributing at this order, hence it contains all the diagrams corresponding to all possible insertions of $k_j^{\mu_j}$ (and $k_j^{\nu_j}$) and therefore, by the Ward identity, all terms $\propto \xi$ vanish. Note that this requires $\mathcal{M}$ to have only on-shell external fermion legs, which is true since $\mathcal{M}$ is an $S$-matrix element. In particular the external photons need not even be on-shell.
Now this is obviously satisfied for the sum of diagrams in Figure 41 in Grozins lecture notes, which you quoted, since these diagrams do not even have external fermion legs. In this example it is particularly easy to see that the three diagrams are precisely the three different ways to insert the photon propagator in the fermion loop and if you have trouble understanding this it may be instructive to verify the Ward identity (and hence the gauge independence) explicitely for this example. Hint for this: Use Eq. (7.65) on p.239 of Peskin.
