code: def cps_loss_computation(
      nranks,
      logits_cons_stu_1,
      logits_cons_stu_2,
      sup_pred_l,
      sup_pred_r,
      ps_label_1,
      ps_label_2,
      gts,
      losses,
  ):
      # cps loss
      cps_loss = losses["types"][0](
          logits_cons_stu_1, ps_label_2
      ) + losses["types"][0](logits_cons_stu_2, ps_label_1)
      if nranks > 1:
          dist.all_reduce(cps_loss, dist.ReduceOp.SUM)
          cps_loss = cps_loss / nranks
      cps_loss = cps_loss * losses["coef"][0]
  
      # sup loss for sub network 1
      loss_sup = losses["types"][1](sup_pred_l, gts)
      if nranks > 1:
          dist.all_reduce(loss_sup, dist.ReduceOp.SUM)
          loss_sup = loss_sup / nranks
      loss_sup = loss_sup * losses["coef"][1]
  
      # sup loss for sub network 2
      loss_sup_r = losses["types"][2](sup_pred_r, gts)
      if nranks > 1:
          dist.all_reduce(loss_sup_r, dist.ReduceOp.SUM)
          loss_sup_r = loss_sup_r / nranks
      loss_sup_r = loss_sup_r * losses["coef"][2]
  
      loss_list = [cps_loss, loss_sup, loss_sup_r]
  
      return loss_list
  
file_path: PaddleSeg/contrib/CrossPseudoSupervision/core/train.py
imports: import os
  import time
  from collections import deque
  import shutil
  import paddle
  import paddle.distributed
  from paddle.io import DistributedBatchSampler, DataLoader
  from paddleseg.utils import TimeAverager, calculate_eta, logger, train_profiler, op_flops_funs
  from paddleseg.core.val import evaluate
  from utils import cps_resume
  from batch_transforms import SegCollate, AddMaskParamsToBatch
label_desc: Use image node_id 2 for calling a global function with example usage: cps_loss_computation(nranks, logits_cons_stu_1, logits_cons_stu_2, sup_pred_l, sup_pred_r, ps_label_1, ps_label_2, gts, losses) and returns: loss_list