I have tried building my own loss function for one hot encoding labels as below :
log_prob = torch.nn.functional.log_softmax(logits_q, dim=1)
loss= -torch.sum(log_prob)*y_qry[i]

but it seems to have error as
RuntimeError: grad can be implicitly created only for scalar outputs

there is usage of
grad = torch.autograd.grad(loss, params)

what may be wrong with the code?