Thank you for your replay. Below is my code.
			neg_targets = sample_neg()
			model.zero_grad()

			pos_score, neg_scores = model(autograd.Variable(torch.LongTensor(inputs_[reviewer][i])),
										  autograd.Variable(torch.LongTensor([targets[reviewer][i][-1]])),
										  autograd.Variable(torch.LongTensor(neg_targets)),
										  rnn_first, rnn_last,
										  autograd.Variable(torch.FloatTensor(queries[reviewer][i])),
										  autograd.Variable(torch.FloatTensor([c_query[reviewer][i][-1]])),
										  update)


			loss = loss_function(pos_score, neg_scores)
			loss.backward()

			nn.utils.clip_grad_norm(model.parameters(), 0.5)
			optimizer.step()

Neg_targets are sampled negative examples. rnn_first, rnn_last and update are bool type, indicate different judgement condition. This is in my train loop.
It can run with retain_graph=True. But I’m not sure which part needs more backward.