Solved by albanD in post #10 
              
              
                Hi, 
In 99.9% of the cases, the output loss is scalar and so what you want here is a single 1 (which is the default value) as this will compute the full gradient of your function. 
If there is more than one output, then there is no natural value to set so it has to be provided by the user. 
Then the…