code: def test_singular_covariance_init_or_prior_strictpd(
      estimator, build_dataset
  ):
      """Tests that when using the 'covariance' init or prior, it returns the
      appropriate error if the covariance matrix is singular, for algorithms
      that need a strictly PD prior or init (see
      https://github.com/scikit-learn-contrib/metric-learn/issues/202 and
      https://github.com/scikit-learn-contrib/metric-learn/pull/195#issuecomment
      -492332451)
      """
      matrices_to_set = []
      if hasattr(estimator, "init"):
          matrices_to_set.append("init")
      if hasattr(estimator, "prior"):
          matrices_to_set.append("prior")
  
      input_data, labels, _, X = build_dataset()
      for param in matrices_to_set:
          model = clone(estimator)
          set_random_state(model)
          # We create a feature that is a linear combination of the first two
          # features:
          input_data = np.concatenate(
              [input_data, input_data[:, ..., :2].dot([[2], [3]])],
              axis=-1,
          )
          model.set_params(**{param: "covariance"})
          msg = (
              "Unable to get a true inverse of the covariance "
              "matrix since it is not definite. Try another "
              "`{}`, or an algorithm that does not "
              "require the `{}` to be strictly positive definite.".format(
                  param, param
              )
          )
          with pytest.raises(LinAlgError) as raised_err:
              model.fit(input_data, labels)
          assert str(raised_err.value) == msg
  
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 19 for calling a global function with example usage: test_singular_covariance_init_or_prior_strictpd(estimator, build_dataset) without return types