Vered_Shoshan:

it’s too long to show here all everything, so I’m trying to think what are the things that caused the omputation graph to detach


Generally, these operations will detach the tensor from the computation graph:

using another library such as numpy without writing custom autograd.Functions including the custom backward function
rewrapping tensors via: x = torch.tensor(x)

explicitly detaching the tensor via: x = x.detach()

using the .data attribute might not detach the tensor directly, but you can run in unwanted side effects so don’t use .data