Hi,
Thanks a lot for your information, I have I have tried to make it and included that tensor in the optimization process. In the part of the attached code, that data tensor that I wanted to include in the optimization process is the (data_words) similarly to (data_phrases).  Data_phrases is optimized successfully and data is updated, so that when I receive the output tensor ( New_phrases_optimized) data is clearly different. However, for (data_words) it is never optimized, so the input data is exactly the same as the output data. Is there any mistake here?
(reminder: the other part of the code is about softmax regression for the phrases, so that the purpose of having words here is only to include in the optimisation process). Should I add (data_words) to the optimizer  in a different way??

for epoch in range(num_epochs):
        print("epoch no. ", epoch + 1)    # training loop
        train_loss = 0
        self.model.train()
        New_words_optimized=[]
        New_phrases_optimized=[]
        for batch_ndx, sample in enumerate(zip(TrainLoader,WordsLoader)):
            self.optimizer.zero_grad()
            data_phrases = Variable(sample[0][0], requires_grad=True)
            data_words = Variable(sample[1][0], requires_grad=True)
            self.data_phrases  = nn.Parameter(data_phrases)
            self.data_words = nn.Parameter(data_words)
            self.optimizer.add_param_group({"params": data_phrases})
            self.optimizer.add_param_group({"params": data_words})
            labels_phrases = sample[0][1].type(torch.LongTensor)-1
            logits, probas = self.model(data_phrases .float())
            loss = self.criterion(logits, labels_phrases) + self.regularizer
            loss.backward(retain_graph=True)
            self.optimizer.step()

            if epoch + 1 == num_epochs:

               phrases_optimized = list(self.parameters())[0].clone()
               words_optimized = list(self.parameters())[1].clone()
               New_phrases_optimized.append(phrases_optimized.detach().numpy())
               New_words_optimized.append(words_optimized.detach().numpy())
            
            train_loss += loss.item()


Thanks a lot
AA