HI ,
I am trying to use this container called  torch::nn::ModuleList it is frustrating that a simple container is implemented this complicated with lack of proper examples. I have looked into API, tests but I cannot figure out how to simply extract the elements inside torch::nn::ModuleList.
What I want is very simple, fill a few Conv2D modules into a  torch::nn::ModuleList inside constructor and use the contents of this list in forward method.
   std::vector<int> mlp_({32, 32, 64});
  torch::nn::ModuleList mlp_convs_;
    for (int i = 0; i < mlp_.size(); i++) {
      mlp_convs_->push_back(
     torch::nn::Conv2d((torch::nn::Conv2dOptions(last_channel_, mlp_.at(i), 1))));
      last_channel_ = mlp_.at(i);
    }

After I fill this mlp_convs_
I want t extract the conv module but no way to get it done.
for (int i = 0; i < mlp_.size(); i++) {

  torch::nn::Conv2d crr_conv = *mlp_convs_->ptr(i); // fails

  auto crr_conv = *mlp_convs_[i]->as<torch::nn::Conv2d>(); // gets it but crr_conv is torch::nn::Conv2dImpl and I need torch::nn::Conv2d



}

Edit;
I end up just using a std::vector for now.