So I was wondering about this so I tried:
A_z = grad(out[:,0].unsqueeze(1),ipt[:,2].unsqueeze(1),torch.ones((batch_size, 1),requires_grad=True).cuda(), create_graph=True)[0]
and got the same error. Is it important that the full input and output tensors are used and not any slices?