code: def test_get_metric_raises_error(estimator, build_dataset):
      """Tests that the metric returned by get_metric raises errors similar to
      the distance functions in scipy.spatial.distance"""
      input_data, labels, _, X = build_dataset()
      model = clone(estimator)
      set_random_state(model)
      model.fit(*remove_y(model, input_data, labels))
      metric = model.get_metric()
  
      list_test_get_metric_raises = [
          (X[0].tolist() + [5.2], X[1]),  # vectors with
          # different dimensions
          (X[0:4], X[1:5]),  # 2D vectors
          (X[0].tolist() + [5.2], X[1] + [7.2]),
      ]
      # vectors of same dimension but incompatible with what the metric learner
      # was trained on
  
      for u, v in list_test_get_metric_raises:
          with pytest.raises(ValueError):
              metric(u, v)
  
imports: from numpy.core.numeric import array_equal
  import pytest
  import re
  import unittest
  import metric_learn
  import numpy
  from sklearn import clone
  from test.test_utils import ids_metric_learners, metric_learners, remove_y
  from metric_learn.sklearn_shims import set_random_state, SKLEARN_AT_LEAST_0_22
label_desc: Use image node_id 4 for calling a global function with example usage: test_get_metric_raises_error(estimator, build_dataset) without return types