Unfortunately, I saved the entire object, and that is what caused the whole problem. Here there is a piece of code that will generate the problem I’m facing right now.
import torch

class Test:
	def __init__(self):
		self.a = min
		self.b = max
		self.c = self.__private  # buggy

	def __private(self):
		return None

test = Test()

torch.save({"test": test}, "file.pkl")
torch.load("file.pkl")

However, if you remove the private attribute from the method, you won’t get any error.
import torch

class Test:
	def __init__(self):
		self.a = min
		self.b = max
		self.c = self.private  # not buggy

	def private(self):
		return None

test = Test()

torch.save({"test": test}, "file.pkl")
torch.load("file.pkl")