code: def undecided_loss(prediction, ground_truth, weight_map=None):
      """
  
      :param prediction:
      :param ground_truth:
      :param weight_map:
      :return:
      """
      ratio_undecided = 1.0 / tf.cast(
          tf.shape(prediction)[-1], tf.float32
      )
      res_undecided = tf.reciprocal(
          tf.reduce_mean(tf.abs(prediction - ratio_undecided), -1)
          + 0.0001
      )
      if weight_map is None:
          return tf.reduce_mean(res_undecided)
      else:
          res_undecided = tf.Print(
              tf.cast(res_undecided, tf.float32),
              [
                  tf.shape(res_undecided),
                  tf.shape(weight_map),
                  tf.shape(res_undecided * weight_map),
              ],
              message="test_printshape_und",
          )
          return tf.reduce_sum(
              res_undecided * weight_map / tf.reduce_sum(weight_map)
          )
  
imports: from __future__ import absolute_import, print_function, division
  import numpy
  import tensorflow
  from niftynet.engine.application_factory import LossSegmentationFactory
  from niftynet.layer.base_layer import Layer
label_desc: Use image node_id 2 for calling a global function with example usage: undecided_loss(prediction, ground_truth, weight_map) and returns: tf, tf