Multiple model inheritance

I guess this questions could also go to Stackoverflow, but I think here I will get a more adequate answer.

I have two model classes:

class Model1(nn.Module):
	def __init__(self, dim1):
		super(Model1, self).__init__()
		self.dim1 = dim1

class Model2(nn.Module):
	def __init__(self, dim2):
		super(Model2, self).__init__()
		self.dim2 = dim2

And I want them to be the two parent classes of a 3rd one. I have tried this:

class Model1Model2(Model1,Model2):
	def __init__(self, dim1, dim2):
        Model1.__init__(self, dim1)
        Model2.__init__(self, dim2)

but when I instantiate the class as: model = Model1Model2(128, 128) I get the following error:

TypeError: __init__() missing 1 required positional argument: 'dim2'

I have also tried this:

class Model1Model2(Model1,Model2):
	def __init__(self, dim1, dim2):
        super(Model1, self).__init__(dim1)
        super(Model2, self).__init__(dim2)

but when I do: model = Model1Model2(128, 128) , I get:

TypeError: __init__() takes 1 positional argument but 2 were given

Anyone knows how one could solve this?
Thanks!

Just in case, someone helped me with the solution:

from torch.nn import Module

class Module1(Module):
    def __init__(self, dim1):
        Module.__init__(self)
        self.dim1 = dim1


class Module2(Module):
    def __init__(self, dim2):
        Module.__init__(self)
        self.dim2=dim2


class Module12(Module1, Module2):
    def __init__(self, dim1, dim2):
        Module1.__init__(self, dim1)
        Module2.__init__(self, dim2)
4 Likes