If you would like to store x in s_list and don’t need to call backward on these tensors in the future, you should store it using s_list.append(x.detach()), since otherwise the computation graph will be stored with each x, which eventually might use all your memory.