code: def triplet_loss(distance="pn"):
      """Returns a previously registered triplet loss function associated
      with the string 'distance'. If passed a callable, just returns it.
      """
      if callable(distance):
          return distance
      try:
          loss_fn = loss_dict[distance]
          return loss_fn
      except KeyError:
          raise ValueError(
              "Loss function {} not registered with ivis".format(
                  distance
              )
          )
  
imports: import functools
  from tensorflow.keras import backend
  import tensorflow
  from tensorflow import keras
  import numpy
  from .distances import euclidean_distance, manhattan_distance, chebyshev_distance, cosine_distance
label_desc: Use image node_id 2 for calling a global function with example usage: triplet_loss(distance) and returns: distance, loss_fn