I guess you know you don’t need PyTorch for this but I assume from your question you want to use PyTorch. Is that right?  If not, you can just use scipy.optimize.minimize(method='BFGS' or 'L-BFGS-B').  Another option is GEKKO 7 but might be overkill for this I’m not sure.