Hi, Alban @albanD
Thanks for your reply; I still have some problem if the input is a batch. I have the following code:
tt1 = test()
x1 = torch.tensor([[1.0], [2.0]], requires_grad = True)
x2 = torch.tensor([[2.0], [3.0]], requires_grad = True)
tt2 = torch.cat([x1, x2], dim = -1)

tt3 = tt1.forward(tt2)

d1, d2 = torch.autograd.grad(tt3, (x1, x2), create_graph = True)

But I got error message:
grad can be implicitly created only for scalar outputs
How can I solve this issue?
Thanks