Nonequilibrium Green’s functions theory: Transport and optical gain in THz quantum cascade lasers