Problem about using "deepcopy(model)"

I find a weird phenomenon when debugging programs these days !
I want to use “deepcopy(model)”, but when there is any assignment of Class Variable like “self.x = XXX”, the program will break and give the error “Only Tensors created explicitly by the user (graph leaves) support the deepcopy protocol at the moment”.
When I change the “self.x=XXX” to “x=XXX”, all is OK.
I try to find why it happens but failed.
Any helpful reply are appreciated.