If the value of the integral
\[ \int_{-\frac{\pi}{2}}^{\frac{\pi}{2}} \left( \frac{x^2 \cos x}{1 + \pi^x} + \frac{1 + \sin^2 x}{1 + e^{\sin^x 2023}} \right) dx = \frac{\pi}{4} (\pi + a) - 2, \]
then the value of \(a\) is: