How to create output equivalent to tf.gradients()?

if you have found the answer to your solution can you share the code please?

thank you !