On checking the inputs passed by the function:
regression_loss, classification_loss = criterion(confidence, locations, labels, boxes) 

I realised locations is a zero tensor as shown here:
tensor([[0, 0, 0,  …, 0, 0, 0],
[0, 0, 0,  …, 0, 0, 0],
[0, 0, 0,  …, 0, 0, 0],
…,
[0, 0, 0,  …, 0, 0, 0],
[0, 0, 0,  …, 0, 0, 0],
[0, 0, 0,  …, 0, 0, 0]])