For future reference, defining a torch module will create a shared pointer to the object, and then torch::save can be used to copy policy net to target net.
struct DQNImpl : torch::nn::Module
{
    torch::nn::Linear layer1;
    torch::nn::Linear layer2;
    torch::nn::Linear layer3;
   
    DQNImpl(int in, int hidden, int out):   layer1(register_module("layer1",torch::nn::Linear(in,hidden))),
                                        layer2(register_module("layer2",torch::nn::Linear(hidden,hidden))),
                                        layer3(register_module("layer3",torch::nn::Linear(hidden,out))){}

  
        torch::Tensor forward(torch::Tensor x){
        x = torch::relu(layer1->forward(x));
        x = torch::relu(layer2->forward(x));
        x= layer3->forward(x);
        return x;
     }
};
TORCH_MODULE(DQN);

int main(){
    DQN policy_net(5,10,3);
    DQN target_net(5,10,3);
    std::stringstream stream;
    torch::save(policy_net,stream);
    torch::load(target_net,stream);
    auto input = torch::ones(5);
    auto output = policy_net->forward(input);
}