Wouldn’t it be simpler just to let the python variable that points to the input go out of scope and wait for it to be garbage collected?
If you try to manage memory in tricksy ways then you can expect lots of headaches in the future. For example any update to pytorch could break your code if you rely on undocumented features like the input data not being used to calculate gradients.