No, I tried this also but I have this error:
main.cpp: In member function ‘at::Tensor NetImpl::forward(at::Tensor)’:
main.cpp:36:25: error: no match for call to ‘(const std::shared_ptr<torch::nn::Module>) (at::Tensor&)’
             x = module(x);

It works only when I defined a Linear layer outside the ModuleList. However I need the layers to be in a ModuleList for the rest of my program.