This loss calculation seems to work for this code snippet:
model = models.resnet50()
out = model(torch.randn(2, 3, 224, 224))
target = torch.zeros(2)

# Clip output, otherwise you might get NaNs
out = torch.clamp(out, 1e-6, out.max().item())
loss = torch.log(out[0]) + torch.sum(torch.abs(out[1:] - target[1:]))
loss.mean().backward()

Note that I had to clamp the output, as I would get NaN values from the log of negative numbers.