I’m a bit confused about what you try to achieve here. Why use an optimizer if you don’t want to learn anything?
For this particular error. Do you have any other information in the stack trace?
Also can you make a small code sample that reproduces this so that I can debug it locally?