To minimize gpu memory usage, how should I sum all the losses?
for epoch in range(epochs):
      for step, data in enumerate(dataloader):
          ...
          total_loss = criterion(input, target) # 1st loss

          second_loss= criterion(input2, target2).item() # 2nd loss
          total_loss += second_loss.item()
          del second_loss

          third_loss = criterion(input3, target3).item() # 3rd loss
          total_Loss += third_loss.item()
          del third_loss
          ...
          optimizer.zero_grad()
          total_loss.backward()
          optimizer.step()