Actually, the implementation is:
        x1,x2,x3,x4,x5,x6,x7,x8 = net(images)

        x1 = criterion(x1, label1)
        x2 = criterion(x2, label2)
        x3 = criterion(x3, label3)

        x5 = criterion(x5, label5)
        x6 = criterion(x6, label6)
        x7 = criterion(x7, label7)
        x8 = criterion(x8, label8)
       
        loss = x1 + x2 + x3 + x5 + x6 + x7 + x8
        loss = loss.mean()
        loss.backward()
        optimizer.step()