Invalid username or password on Android lock screen when 2 step verification is enabled
In the username field are you providing the entire email address i.e. shubham@gmail.com or only shubham? The login works better if the email is provided.

Also if you are offline and got locked out from the phone, the only option is hard reset. If you were rooted and have USB Debugging enabled then it's a different story.

But if your connected to wifi or if mobile data is on, then the forgot pattern (or similar) would be working.