Solved by Meltemology in post #2 
              
              
                I am also new to Pytorch but as I understood in this thread 
https://discuss.pytorch.org/t/simulated-annealing-custom-optimizer/38609 people implemented custom optimizers.