PLUGIn: A simple algorithm for inverting generative models with recovery guarantees