code: def compute_generalisation_loss(validation_his):
      """
      This function computes the generalisation loss as
          l[-1]-min(l)/max(l)-min(l)
      :param validation_his: performance history
      :return: generalisation loss
      """
      min_val_loss = np.min(np.array(validation_his))
      max_val_loss = np.max(np.array(validation_his))
      last = validation_his[-1]
      if min_val_loss == 0:
          return last
      return (last - min_val_loss) / (max_val_loss - min_val_loss)
  
file_path: NiftyNet/niftynet/engine/handler_early_stopping.py
imports: import numpy
  import tensorflow
  from scipy.ndimage import median_filter
  from niftynet.engine.signal import ITER_FINISHED
label_desc: Use image node_id 1 for calling a global function with example usage: compute_generalisation_loss(validation_his) and returns: unknown, last