class_docstr: SOLOv2Loss
  Args:
      ins_loss_weight (float): Weight of instance loss.
      focal_loss_gamma (float): Gamma parameter for focal loss.
      focal_loss_alpha (float): Alpha parameter for focal loss.
class_docstr_tok: ["SOLOv2Loss","Args",":","ins_loss_weight","(","float",")",":","Weight","of","instance","loss",".","focal_loss_gamma","(","float",")",":","Gamma","parameter","for","focal","loss",".","focal_loss_alpha","(","float",")",":","Alpha","parameter","for","focal","loss","."]
docstr: Get loss of network of SOLOv2.
  Args:
      ins_pred_list (list): Variable list of instance branch output.
      ins_label_list (list): List of instance labels pre batch.
      cate_preds (list): Concat Variable list of categroy branch output.
      cate_labels (list): Concat list of categroy labels pre batch.
      num_ins (int): Number of positive samples in a mini-batch.
  Returns:
      loss_ins (Variable): The instance loss Variable of SOLOv2 network.
      loss_cate (Variable): The category loss Variable of SOLOv2 network.
docstr_tok: ["Get","loss","of","network","of","SOLOv2",".","Args",":","ins_pred_list","(","list",")",":","Variable","list","of","instance","branch","output",".","ins_label_list","(","list",")",":","List","of","instance","labels","pre","batch",".","cate_preds","(","list",")",":","Concat","Variable","list","of","categroy","branch","output",".","cate_labels","(","list",")",":","Concat","list","of","categroy","labels","pre","batch",".","num_ins","(","int",")",":","Number","of","positive","samples","in","a","mini-batch",".","Returns",":","loss_ins","(","Variable",")",":","The","instance","loss","Variable","of","SOLOv2","network",".","loss_cate","(","Variable",")",":","The","category","loss","Variable","of","SOLOv2","network","."]
code: def __call__(
      self,
      ins_pred_list,
      ins_label_list,
      cate_preds,
      cate_labels,
      num_ins,
  ):
      """
      Get loss of network of SOLOv2.
      Args:
          ins_pred_list (list): Variable list of instance branch output.
          ins_label_list (list): List of instance labels pre batch.
          cate_preds (list): Concat Variable list of categroy branch output.
          cate_labels (list): Concat list of categroy labels pre batch.
          num_ins (int): Number of positive samples in a mini-batch.
      Returns:
          loss_ins (Variable): The instance loss Variable of SOLOv2 network.
          loss_cate (Variable): The category loss Variable of SOLOv2 network.
      """
  
      # 1. Ues dice_loss to calculate instance loss
      loss_ins = []
      total_weights = paddle.zeros(shape=[1], dtype="float32")
      for input, target in zip(ins_pred_list, ins_label_list):
          if input is None:
              continue
          target = paddle.cast(target, "float32")
          target = paddle.reshape(
              target,
              shape=[
                  -1,
                  paddle.shape(input)[-2],
                  paddle.shape(input)[-1],
              ],
          )
          weights = paddle.cast(
              paddle.sum(target, axis=[1, 2]) > 0, "float32"
          )
          input = F.sigmoid(input)
          dice_out = paddle.multiply(
              self._dice_loss(input, target), weights
          )
          total_weights += paddle.sum(weights)
          loss_ins.append(dice_out)
      loss_ins = paddle.sum(paddle.concat(loss_ins)) / total_weights
      loss_ins = loss_ins * self.ins_loss_weight
  
      # 2. Ues sigmoid_focal_loss to calculate category loss
      # expand onehot labels
      num_classes = cate_preds.shape[-1]
      cate_labels_bin = F.one_hot(
          cate_labels, num_classes=num_classes + 1
      )
      cate_labels_bin = cate_labels_bin[:, 1:]
  
      loss_cate = F.sigmoid_focal_loss(
          cate_preds,
          label=cate_labels_bin,
          normalizer=num_ins + 1.0,
          gamma=self.focal_loss_gamma,
          alpha=self.focal_loss_alpha,
      )
  
      return loss_ins, loss_cate
  
file_path: PaddleDetection/ppdet/modeling/losses/solov2_loss.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import paddle
  import paddle.nn.functional
  from ppdet.core.workspace import register, serializable
label_desc: Use image node_id 3 for calling the SOLOv2Loss obj's underlying member method code with example usage: obj.__call__(ins_pred_list, ins_label_list, cate_preds, cate_labels, num_ins) and returns: loss_ins,  loss_cate