Try something like this:
class NN(nn.Module):
    def __init__(self):
        super(NN, self).__init__()
        linear_layers = []
        for i in range(10):
            linear_layers.append(nn.Linear(5,5))
        self.net = nn.Sequential(*linear_layers)