Solved by albanD in post #2 
              
              
                Hi, 
Option (1) is the old way to define Functions. This does not support gradients of gradients and it’s support might be discontinued in the future (not sure when). 
The second one is the way to go. Note that you can do exactly the same thing as you can save arbitrary stuff in the ctx (the same wa…