code: def _select_distance_fn(key):
      """Selects the distance function."""
      if key == configs.DistanceType.L1:
          return tf.compat.v1.losses.absolute_difference
      elif key == configs.DistanceType.L2:
          return tf.compat.v1.losses.mean_squared_error
      elif key == configs.DistanceType.COSINE:
          return tf.compat.v1.losses.cosine_distance
      elif key == configs.DistanceType.JENSEN_SHANNON_DIVERGENCE:
          return jensen_shannon_divergence
      elif key == configs.DistanceType.KL_DIVERGENCE:
          return kl_divergence
      else:
          raise ValueError("Invalid configs.DistanceType %s." % key)
  
file_path: neural-structured-learning/neural_structured_learning/lib/distances.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import neural_structured_learning.configs
  import tensorflow
label_desc: Use image node_id 7 for calling a global function with example usage: _select_distance_fn(key) and returns: tf, tf, tf, jensen_shannon_divergence, kl_divergence