How to implement a parallel block?

I am trying to solve the Exercise 4 in Section 5.1, which is “Implement a block that takes two blocks as an argument, say net1 and net2 and returns the concatenated output of both networks in the forward pass (this is also called a parallel block).”

I am trying to implement the multiple inheritance via:

class Concatenate(nn.Block, nn.Block):
def init(self, **kwargs):
super(Concatenate, self).init(**kwargs)

But this seems not the correct way to implement multiple inheritance, can anyone give me any hint?

This is not really a case of multiple inheritance, your class should be defined that way class Concatenate(nn.Block), however you want the constructor to have 2 blocks as input and look like that: def __init__(self, block1, block2, **kwargs):

For example:

 class ParallelMLP(nn.Block):
        def __init__(self, **kwargs):
            super(ParallelMLP, self).__init__(**kwargs)
            self.input_net1 = nn.Sequential()
            for item1 in net1:
                self.input_net1.add(item1)
            self.input_net1.add(nn.Dense(1))
            
            self.input_net2 = nn.Sequential()
            for item2 in net2:
                self.input_net2.add(item2)
            self.input_net2.add(nn.Dense(1))

        def forward(self, x):
            out1 = self.input_net1(x)
            out2 = self.input_net2(x)
            return out2#mx.nd.concat(out1, out2, dim=0)

        
    x = nd.random.uniform(shape=(2, 20))
    net1 = [nn.Dense(64, activation='relu'), nn. Dense(32, activation='relu')]
    net2 = [nn.Dense(64, activation='relu')]
    parallel = ParallelMLP()
    parallel.initialize()
    parallel(x)