Hdk:

Can you please explain the remaining code?


I think @user432 could better explain the posted code, as I’m unfortunately not familiar with the mentioned paper. 



 Hdk:

I don’t know what line no.231 ( losses.update(loss.item(), bsz ) does. I guess it’s just for printing purpose only.


Yes, the AverageMeter object (which is the class of the losses object) is used for printing purposes and supports calculating the average etc.