Do gradient descent once an epoch cooperating with dataloader

hi, I am new to pytorch and I am trying to do pseudo-label on an image segmentation task. I am struggling to implement loss.backward() in the training process. From the original paper, if I am correct, the loss will be accumulated for all mini-batch in an epoch and do back propagate once an epoch. I am not sure how to implement this.

Original paper is on: pseudo-label paper