code: def dice_dense(prediction, ground_truth, weight_map=None):
      """
      Computing mean-class Dice similarity.
  
      :param prediction: last dimension should have ``num_classes``
      :param ground_truth: segmentation ground truth (encoded as a binary matrix)
          last dimension should be ``num_classes``
      :param weight_map:
      :return: ``1.0 - mean(Dice similarity per class)``
      """
  
      if weight_map is not None:
          raise NotImplementedError
      prediction = tf.cast(prediction, dtype=tf.float32)
      ground_truth = tf.cast(ground_truth, dtype=tf.float32)
      ground_truth = tf.reshape(ground_truth, prediction.shape)
      # computing Dice over the spatial dimensions
      reduce_axes = list(range(len(prediction.shape) - 1))
      dice_numerator = 2.0 * tf.reduce_sum(
          prediction * ground_truth, axis=reduce_axes
      )
      dice_denominator = tf.reduce_sum(
          tf.square(prediction), axis=reduce_axes
      ) + tf.reduce_sum(tf.square(ground_truth), axis=reduce_axes)
  
      epsilon = 0.00001
  
      dice_score = (dice_numerator + epsilon) / (
          dice_denominator + epsilon
      )
      return 1.0 - tf.reduce_mean(dice_score)
  
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 15 for calling a global function with example usage: dice_dense(prediction, ground_truth, weight_map) and returns: unknown