code: def l2_loss(prediction, ground_truth, weight_map=None):
      """
      :param prediction: the current prediction of the ground truth.
      :param ground_truth: the measurement you are approximating with regression.
      :return: sum(differences squared) / 2 - Note, no square root
      """
  
      residuals = tf.subtract(prediction, ground_truth)
      if weight_map is not None:
          residuals = tf.multiply(
              residuals, weight_map
          ) / tf.reduce_sum(weight_map)
      return tf.nn.l2_loss(residuals)
  
file_path: NiftyNet/niftynet/layer/loss_regression.py
imports: from __future__ import absolute_import, print_function, division
  import tensorflow
  from niftynet.engine.application_factory import LossRegressionFactory
  from niftynet.layer.base_layer import Layer
label_desc: Use image node_id 2 for calling a global function with example usage: l2_loss(prediction, ground_truth, weight_map) and returns: tf