Looking at pytorch sources, I see two implementations:
caffe (no longer used?)
const float nexpY = exp(-Y[i]);
dX[i] = dY[i] * (1 - nexpY);

aten (a=X, b=Y)
scalar_t z = std::exp(b * beta);
return (b * beta) > threshold ? a : a * (z - scalar_t(1.)) / z;

below threshold case is equiv. to caffe:
 dX = dY * (exp(Y)-1)/exp(Y) = dY * (1 - exp(-Y))

Notice that caffe version doesn’t need the X tensor. So, are there any problems with using that? (in the most common case, with beta=1, and hessian not needed). Is caffe implementation built-in/exported to python?