There was actually a part right after he was kidnapped, basically turning the robot on where he demanded to be allowed to come back every day to teach the robot..... this was at a point where they had just threatened to cut his feet off. They hadn't agreed to let him go, so him assuming he was being let go and could come back was just literally horrific writing. It was the writer knowing they were going to let him go in the future, but adding that into the characters dialogue before he knew he was going to be released. That isn't a plot hole as much as it's just a writing failure.
In this situation, criminals attempting to take control of a robot and threatening to kill you, you assume they are going to kill you, not let you go. You say you'll enable the robot if they let you go, something along those lines. So so so poorly written.
That ignores the issue of, why let him go, why wouldn't he call the cops, have them all killed, take the robot back... regardless of what minor trouble he would be in, it was nothing compared to leaving the guardkey with known criminals.
Hell if he wanted to teach the thing why would he want to leave? He's willing to come back there and not tell the authorities but he's willing to leave and let a bunch of gangsters teach it to be a criminal.
Everything about it was just embarrassingly stupid. $50mil spent so poorly, Couple less scenes with the robot, 5mil saved and put that into the script and hiring a better cast and it could have been so much better.