send some soldier back in time to protect the leader of THE RESISTANCE from assassination, so he can lead THE RESISTANCE against the machines. Thats the only solution. Humanity will survive, but will be decimated by figures.
.. this might and will lead to a time loop, somehow. In each scenario, AI can't be defeated without much losses. And, not when it fully evolved. We need to stop the development, now!