How to use a loss functions closed-form gradient even when it does not have a closed-form itself I have a loss function without a closed analytic form that I want to implement in tensorflow that has a nice clean gradient (i.e. i have some nice gradient function $f(x)$ that i want to use for backprop but $\int_x f(x) \ dx$ is with no closed form)

Ofcourse i wouldnt be able to evaluate the loss, but i want to use $f(x)$ in the optimization process. How could this be accomplished?
TensorFlow allows for custom gradient functions with tf.custom_gradient.

You could write a decorator that would return specific gradient values for specific values of x. The loss function would not need to be evaluated.