Thanks a ton! Solution 1 worked like a charm.
I tested it out on TPU on Mnist with 4 partitions. If you would like to take a look at my toy example, whether it can be of any use, to serve as an example, I’d love to share it.
I also wanted to ask whether the same is possible using tf.gradients? Is the argument grad_ys in its documentation equivalent to output_gradients?