Let’s say I have this Template class
class Template(nn.Module):
    def __init__(self):
        super().__init__()
    def forward(self, *input):
        pass

and I would like to build a model out of multiple instance of Template, given a specific number of layers.
class BuildModel(nn.Module):
    def __init__(self, number_of_layers):
        super().__init__()
        # self.layer_n = Template() for n in range(0, number_of_layers)
    def forward(self, *input):
        pass

I thought to implement this with a list of Template's instances, but soon realised this won’t go through the nn.Module's __setattr__. So, how to handle this situation of building a model out of multiple sub-modules given a layer count?
Idea
Hmm… Would setattr(self, 'layer_n', Template()) be a solution?