docstr: Compute the losses in the case of a multirater setting
  :param pred_ave: average of the predictions over the different raters
  :param pred_multi: prediction for each individual rater
  :param ground_truth: ground truth classification for each individual
  rater
  :param weight_batch:
  :param var_scope:
  :return:
docstr_tok: ["Compute","the","losses","in","the","case","of","a","multirater","setting",":","param","pred_ave",":","average","of","the","predictions","over","the","different","raters",":","param","pred_multi",":","prediction","for","each","individual","rater",":","param","ground_truth",":","ground","truth","classification","for","each","individual","rater",":","param","weight_batch",":",":","param","var_scope",":",":","return",":"]
code: def layer_op(
      self,
      pred_ave=None,
      pred_multi=None,
      ground_truth=None,
      weight_batch=None,
      var_scope=None,
  ):
      """
      Compute the losses in the case of a multirater setting
      :param pred_ave: average of the predictions over the different raters
      :param pred_multi: prediction for each individual rater
      :param ground_truth: ground truth classification for each individual
      rater
      :param weight_batch:
      :param var_scope:
      :return:
      """
  
      with tf.device("/cpu:0"):
          if ground_truth is not None:
              ground_truth = tf.reshape(
                  ground_truth,
                  [-1, self._num_raters, self._num_classes],
              )
          if pred_ave is not None:
              if not isinstance(pred_ave, (list, tuple)):
                  pred_ave = [pred_ave]
              if self._num_classes > 0 and pred_ave is not None:
                  # reshape the prediction to [n_voxels , num_classes]
                  pred_ave = [
                      tf.reshape(pred, [-1, self._num_classes])
                      for pred in pred_ave
                  ]
          if pred_multi is not None and not isinstance(
              pred_multi, (list, tuple)
          ):
              pred_multi = [pred_multi]
              if self._num_classes > 0 and pred_multi is not None:
                  pred_multi = [
                      tf.reshape(
                          pred,
                          [-1, self._num_raters, self._num_classes],
                      )
                      for pred in pred_multi
                  ]
  
          data_loss = []
          if ground_truth is not None:
              if pred_multi is not None:
                  if pred_ave is not None:
                      for pred, pred_mul in zip(pred_ave, pred_multi):
                          if self._loss_func_params:
                              data_loss.append(
                                  self._data_loss_func(
                                      ground_truth,
                                      pred,
                                      pred_mul,
                                      **self._loss_func_params,
                                  )
                              )
                          else:
                              data_loss.append(
                                  self._data_loss_func(
                                      ground_truth, pred, pred_mul
                                  )
                              )
                  else:
                      for pred_mul in pred_multi:
                          if self._loss_func_params:
                              data_loss.append(
                                  self._data_loss_func(
                                      ground_truth,
                                      pred_mul,
                                      **self._loss_func_params,
                                  )
                              )
                          else:
                              data_loss.append(
                                  self._data_loss_func(
                                      ground_truth, pred_mul
                                  )
                              )
              else:
                  for pred in pred_ave:
                      if self._loss_func_params:
                          data_loss.append(
                              self._data_loss_func(
                                  pred,
                                  ground_truth,
                                  **self._loss_func_params,
                              )
                          )
                      else:
                          data_loss.append(
                              self._data_loss_func(pred, ground_truth)
                          )
          elif pred_multi is not None:
              for pred, pred_mul in zip(pred_ave, pred_multi):
                  if self._loss_func_params:
                      data_loss.append(
                          self._data_loss_func(
                              pred, pred_mul, **self._loss_func_params
                          )
                      )
                  else:
                      data_loss.append(
                          self._data_loss_func(pred, pred_mul)
                      )
  
          if weight_batch is not None:
              return tf.reduce_mean(
                  weight_batch
                  / tf.reduce_sum(weight_batch)
                  * data_loss[0]
              )
          else:
              return tf.reduce_mean(data_loss)
  
file_path: NiftyNet/niftynet/layer/loss_classification_multi.py
imports: from __future__ import absolute_import, print_function, division
  import numpy
  import tensorflow
  from niftynet.engine.application_factory import LossClassificationMultiFactory
  from niftynet.layer.base_layer import Layer
label_desc: Use image node_id 3 for calling the LossFunction obj's underlying member method code with example usage: obj.layer_op(pred_ave, pred_multi, ground_truth, weight_batch, var_scope) and returns: tf, tf