I have a normal class (which is not an instance of anything like nn.Module or something), and inside that, I have some instances from two other classes which are inheritances of nn.Module.
For using my model on GPU, I’ve defined a function which calls .cuda() for every nn.Module instances. But after running the code, maybe by calling this function, my main model turns to None. Actually, the structure of my models is something like as follows:
class main:
    def __init__(self):
        self.a = A()
        self.b = []
        for i in range(5):
            self.b.append(B())

    def cuda(self):
        self.a.cuda()
        for b in self.b:
            b.cuda()


class A(nn.Module):
    def __init__(self):
        ...


class B(nn.Module):
    def __init__(self):
        ...