If I change the NegateGradient as follows:
class NegateGradient(Function):
    @staticmethod
    def forward(ctx, input, a):
        ctx.a = a
        ctx.mark_dirty(x)

        return x

    @staticmethod
    def backward(ctx, grad_output):
        output = -grad_output * ctx.a

        return output, None

It raises error: one of the variables need for gradient computation has been modified by an inplace operation, can you explain it?