code: def test_get_metric_is_pseudo_metric(estimator, build_dataset):
      """Tests that the get_metric method of mahalanobis metric learners returns a
      pseudo-metric (metric but without one side of the equivalence of
      the identity of indiscernables property)
      """
      input_data, labels, _, X = build_dataset()
      model = clone(estimator)
      set_random_state(model)
      model.fit(*remove_y(estimator, input_data, labels))
      metric = model.get_metric()
  
      n_features = X.shape[1]
      for seed in range(10):
          rng = np.random.RandomState(seed)
          a, b, c = (rng.randn(n_features) for _ in range(3))
          assert metric(a, b) >= 0  # positivity
          assert metric(a, b) == metric(b, a)  # symmetry
          # one side of identity indiscernables: x == y => d(x, y) == 0. The other
          # side of the equivalence is not always true for Mahalanobis distances.
          assert metric(a, a) == 0
          # triangular inequality
          assert metric(a, c) < metric(a, b) + metric(
              b, c
          ) or np.isclose(
              metric(a, c), metric(a, b) + metric(b, c), rtol=1e-20
          )
  
imports: from itertools import product
  import pytest
  import numpy
  from numpy.linalg import LinAlgError
  from numpy.testing import assert_array_almost_equal, assert_allclose, assert_array_equal
  from scipy.spatial.distance import pdist, squareform, mahalanobis
  from scipy.stats import ortho_group
  from sklearn import clone
  from sklearn.cluster import DBSCAN
  from sklearn.datasets import make_spd_matrix, make_blobs
  from sklearn.utils import check_random_state, shuffle
  from sklearn.utils.multiclass import type_of_target
  from metric_learn.sklearn_shims import set_random_state
  from metric_learn._util import make_context, _initialize_metric_mahalanobis
  from metric_learn.sdml import _BaseSDML
  from metric_learn.base_metric import _QuadrupletsClassifierMixin, _TripletsClassifierMixin, _PairsClassifierMixin
  from metric_learn.exceptions import NonPSDError
  from test.test_utils import ids_metric_learners, metric_learners, remove_y, ids_classifiers
label_desc: Use image node_id 12 for calling a global function with example usage: test_get_metric_is_pseudo_metric(estimator, build_dataset) without return types