code: def test_init_transformation(estimator, build_dataset):
      input_data, labels, _, X = build_dataset()
      is_classification = type_of_target(labels) in [
          "multiclass",
          "binary",
      ]
      model = clone(estimator)
      rng = np.random.RandomState(42)
  
      # Start learning from scratch
      model.set_params(init="identity")
      model.fit(input_data, labels)
  
      # Initialize with random
      model.set_params(init="random")
      model.fit(input_data, labels)
  
      # Initialize with auto
      model.set_params(init="auto")
      model.fit(input_data, labels)
  
      # Initialize with PCA
      model.set_params(init="pca")
      model.fit(input_data, labels)
  
      # Initialize with LDA
      if is_classification:
          model.set_params(init="lda")
          model.fit(input_data, labels)
  
      # Initialize with a numpy array
      init = rng.rand(X.shape[1], X.shape[1])
      model.set_params(init=init)
      model.fit(input_data, labels)
  
      # init.shape[1] must match X.shape[1]
      init = rng.rand(X.shape[1], X.shape[1] + 1)
      model.set_params(init=init)
      msg = (
          "The input dimensionality ({}) of the given "
          "linear transformation `init` must match the "
          "dimensionality of the given inputs `X` ({}).".format(
              init.shape[1], X.shape[1]
          )
      )
      with pytest.raises(ValueError) as raised_error:
          model.fit(input_data, labels)
      assert str(raised_error.value) == msg
  
      # init.shape[0] must be <= init.shape[1]
      init = rng.rand(X.shape[1] + 1, X.shape[1])
      model.set_params(init=init)
      msg = (
          "The output dimensionality ({}) of the given "
          "linear transformation `init` cannot be "
          "greater than its input dimensionality ({}).".format(
              init.shape[0], init.shape[1]
          )
      )
      with pytest.raises(ValueError) as raised_error:
          model.fit(input_data, labels)
      assert str(raised_error.value) == msg
  
      # init.shape[0] must match n_components
      init = rng.rand(X.shape[1], X.shape[1])
      n_components = X.shape[1] - 1
      model.set_params(init=init, n_components=n_components)
      msg = (
          "The preferred dimensionality of the "
          "projected space `n_components` ({}) does not match "
          "the output dimensionality of the given "
          "linear transformation `init` ({})!".format(
              n_components, init.shape[0]
          )
      )
      with pytest.raises(ValueError) as raised_error:
          model.fit(input_data, labels)
      assert str(raised_error.value) == msg
  
      # init must be as specified in the docstring
      model.set_params(init=1)
      msg = (
          "`init` must be 'auto', 'pca', 'identity', "
          "'random'{} or a numpy array of shape "
          "(n_components, n_features).".format(
              ", 'lda'" if is_classification else ""
          )
      )
      with pytest.raises(ValueError) as raised_error:
          model.fit(input_data, labels)
      assert str(raised_error.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 16 for calling a global function with example usage: test_init_transformation(estimator, build_dataset) without return types