Are the C++ frontend optimizers supposed to work with script modules?

I load the torchscript module with torch::jit::load, the module’s parameters doesn’t update while training, how can i train the torchscript module?
here are some codes:

for(int epoch=0;epoch < 3;++epoch){
        model.train(true);
        optimizer.zero_grad();
        for(int step=0;step<nums;++step){
            std::vector<torch::jit::IValue> train_inputs1;
            train_inputs1.emplace_back(inputs_texts[step]);
            train_inputs1.emplace_back(inputs_pos_tags[step]);
            at::Tensor pos_scores = model.forward(train_inputs1).toTensor();

            std::vector<torch::jit::IValue> train_inputs2;
            train_inputs2.emplace_back(inputs_texts[step]);
            train_inputs2.emplace_back(inputs_neg_tags[step]);
            at::Tensor neg_scores = model.forward(train_inputs2).toTensor();

            at::Tensor loss = loss_func(pos_scores,neg_scores);
            loss.backward({},true,false);
//            loss.backward();
            optimizer.step();
            cout<<loss<<endl;
        }
        cout<<"epoch: "<<epoch<<"/3 completed!\n";
        model.save("./testsave.pt");
    }

the loss didn’t change for every epoch.

Hi,

This does not work currently I think. You can check this issue to track the progress on fixing this: https://github.com/pytorch/pytorch/issues/28478