code: def dice(predictions, labels, num_classes):
      """Calculates the categorical Dice similarity coefficients for each class
          between labels and predictions.
  
      Args:
          predictions (np.ndarray): predictions
          labels (np.ndarray): labels
          num_classes (int): number of classes to calculate the dice
              coefficient for
  
      Returns:
          np.ndarray: dice coefficient per class or NaN if class not present
      """
  
      dice_scores = np.zeros((num_classes))
      for i in range(num_classes):
          tmp_den = np.sum(predictions == i) + np.sum(labels == i)
          tmp_dice = (
              2.0 * np.sum((predictions == i) * (labels == i)) / tmp_den
          )
          dice_scores[i] = tmp_dice
      return dice_scores.astype(np.float32)
  
imports: from __future__ import division
  from __future__ import absolute_import
  from __future__ import print_function
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: dice(predictions, labels, num_classes) and returns: dice_scores