My best guess is that losses might be an object tracking some internal stats as floats and losses.val as well as losses.avg would already be float values (not tensors), so you could remove the .item() call.