code: def test_custom_loss_ivis(model_filepath):
      iris = datasets.load_iris()
      X = iris.data
  
      def euclidean_loss(y_true, y_pred):
          margin = 1
          anchor, positive, negative = tf.unstack(y_pred)
          return K.mean(
              K.maximum(
                  euclidean_distance(anchor, positive)
                  - euclidean_distance(anchor, negative)
                  + margin,
                  0,
              )
          )
  
      model = Ivis(
          distance=euclidean_loss, k=15, batch_size=16, epochs=3
      )
      y_pred = model.fit_transform(X)
  
      # Test model saving and loading
      model.save_model(model_filepath, overwrite=True)
      model_2 = Ivis(distance=euclidean_loss)
      model_2.load_model(model_filepath)
  
      model_3 = Ivis()
      with pytest.raises(ValueError):
          model_3.load_model(model_filepath)
  
file_path: ivis/tests/nn/test_losses.py
imports: import tempfile
  import os
  import pytest
  from sklearn import datasets
  from tensorflow.keras import backend
  import tensorflow
  from ivis.nn import losses
  from ivis.nn.distances import euclidean_distance
  from ivis import Ivis
label_desc: Use image node_id 4 for calling a global function with example usage: test_custom_loss_ivis(model_filepath) and returns: K