I simplify the thing but I want to build the following structure:
x -> [Encoder] -> x_encoded
x_encoded -> [predictor 1] -> y_1
x_encoded -> [predictor 2] -> y_2
…
x_encoded -> [predictor n] -> y_n
output = concat(y_1, …, y_n)
All the different predictors have the same structure so I did something like that:
 self.predictors = nn.ModuleDict()
 for i in range(n):
        self.predictors["predictor_" + str(i)] = nn.Sequential(
                << STRUCTURE OF THE PREDICTORS >>
            )

And my forward will be something like:
def forward(self, x):
        #Encoder
        x =  self.encoder(x)
        #Predictors
        output = torch.cat(tuple(
                      self.predictors["predictor_" + str(i)](x) for i in range(n))
                      )

Is it the right way to do it ?