How Can I write a new optimizer in pytorch?

I’m planning on creating a new optimizer like Adadelta in pytorch, but I have no idea where to start and how to go about it!
Do I need to write everything in C and then create a python wrapper for it? or Is it actually possible to implement everything in python? and if I do so, will it be available on GPU as well or CPU only ?
I would be grateful if anyone could direct me in the correct path .
Best Regards