code: def cross_entropy(prediction, ground_truth):
      """
      Function to calculate the cross entropy loss
      :param prediction: the logits (before softmax)
      :param ground_truth: the classification ground truth
      :return: the loss
      """
      ground_truth = tf.to_int64(ground_truth)
      loss = tf.nn.sparse_softmax_cross_entropy_with_logits(
          logits=prediction, labels=ground_truth
      )
      return loss
  
file_path: NiftyNet/niftynet/layer/loss_classification.py
imports: from __future__ import absolute_import, print_function, division
  import numpy
  import tensorflow
  from niftynet.engine.application_factory import LossClassificationFactory
  from niftynet.layer.base_layer import Layer
label_desc: Use image node_id 1 for calling a global function with example usage: cross_entropy(prediction, ground_truth) and returns: loss