Most better sequencers have a feature called a tempo map that does this.
But if they're mistakes, then why would you want the tempo to match the mistakes if you're going to correct them? Sounds very ass-backwards to me. Maybe you can explain what you're trying to do and someone here can offer suggestions.