Thanks for your answer.
I dont think you can write a normal python function and use it in pytorch. Unless they change it.
It has to be in pytorch to be able to do backpropagation.
Can you give me a simple example?