I think the way it works in Julia and PyTorch environments is they run the code forwards once, write the derivatives to some kind of tape, and then use reflection services to walk the tape backwards and output the code to backpropagate changes.
That is a bit trickier to do in Nim.
