I see. What I want to do is something like this:
class AFunc(Function):
    @staticmethod
    def forward(ctx, x):
        res = function(x)
        ctx.save_for_backward(x, res)
        return res

    @staticmethod
    def backward(ctx, grad_output):
        x, res = ctx.saved_tensors
        res.inplace_op_(x)
        return res

x = torch.rand(1,1)
res = SomeFunc.apply(x)
out = use_res_func(res) 
out.backward()

So I want to modify during the backward pass while the computation graph is not (entirely?) freed.
Since I want to modify res and not x, it’d be fine because res is created in the forward function, and when backward is reached, no other node in the remaining graph will use res anyhow.
How do I tell PyTorch that it is okay to modify res in the backward function?