I have got some strange issues as shown below,
I use Pytorch,
the “.item()” costs too much time according to the results from kernprof which is not expected.

image.png915×392 57.6 KB

If I comment out the first row using .item() (“train_loss += loss.item()”)
Then the most time-consuming part will be the next row using .item() as below, where .item() is only a transform from tensor to scalar, is it so time-consuming?