Well, it seems that piece does work for me:
    @staticmethod
    def forward(ctx, s, a):
        k = 1 / (a + s - a * s)

        ctx.save_for_backward(s, a, k)

        return k * s

    @staticmethod
    def backward(ctx, grad_output):
        s, a, k = ctx.saved_tensors
        grad_s = None
        grad_s = k + s * (a - 1) * (k ** 2)

        return grad_output * grad_s, None