Hello, I have a problem when my model is running.
I have searched for the solution but I didn’t find it anywhere.
So hopefully I would get the solution here.
I have a piece of code generating a ModuleList in the init() method.
            if pooling_type == 1:
                maxpool = nn.MaxPool2d(kernel, stride=stride, return_indices=True)
                module_block.add_module('maxpool2d_{}'.format(index), maxpool)
            else:
                maxunpool = nn.MaxUnpool2d(kernel, stride=stride)
                module_block.add_module('maxunpool2d_{}'.format(index), maxunpool)


Then in the forward(), I have this code.
                if pooling_type == 1:
                    x, return_ids[index] = self.module_list[index](x)
                else:           # unpooling layer must be supplied with ids.
                    ids_from = int(module['ids_from'])
                    ids = return_ids[ids_from]
                    x = self.module_list[index](x, ids)


self.module_list is a ModuleList generated in the init method.
I keep the return_indices in a dictionary called return_ids.
However when it came to unpooling layer, it threw an error that
TypeError: forward() takes 2 positional arguments but 3 were given

PS.
module_block is nn.Sequential().
I am not sure what is wrong with the code.
Has anyone experienced this error?