gt_coord = torch.empty(34,requires_grad=False)
gt_coord = gt[i,:,j]

Here you first create a tensor that doesnt require gradients, and then you overwrite it with a tensor that does require gradient. I think just writing:
gt_coord = gt[i,:,j].detach().numpy()

should work (https://pytorch.org/docs/stable/autograd.html#torch.Tensor.detach 4)