code: def test_auto_init_transformation(
      n_samples,
      n_features,
      n_classes,
      n_components,
      estimator,
      build_dataset,
  ):
      # Test that auto choose the init transformation as expected with every
      # configuration of order of n_samples, n_features, n_classes and
      # n_components, for all metric learners that learn a transformation.
      if n_classes >= n_samples:
          pass
          # n_classes > n_samples is impossible, and n_classes == n_samples
          # throws an error from lda but is an absurd case
      else:
          input_data, labels, _, X = build_dataset()
          model_base = clone(estimator)
          rng = np.random.RandomState(42)
          model_base.set_params(
              init="auto", n_components=n_components, random_state=rng
          )
          # To make the test work for LMNN:
          if "LMNN" in model_base.__class__.__name__:
              model_base.set_params(n_neighbors=1)
          # To make the test faster for estimators that have a max_iter:
          if hasattr(model_base, "max_iter"):
              model_base.set_params(max_iter=1)
          if n_components > n_features:
              # this would return a ValueError, which is tested in
              # test_init_transformation
              pass
          else:
              # We need to build a dataset of the right shape:
              num_to_pad_n_samples = (
                  n_samples // input_data.shape[0] + 1
              )
              num_to_pad_n_features = (
                  n_features // input_data.shape[-1] + 1
              )
              if input_data.ndim == 3:
                  input_data = np.tile(
                      input_data,
                      (
                          num_to_pad_n_samples,
                          input_data.shape[1],
                          num_to_pad_n_features,
                      ),
                  )
              else:
                  input_data = np.tile(
                      input_data,
                      (num_to_pad_n_samples, num_to_pad_n_features),
                  )
              input_data = input_data[:n_samples, ..., :n_features]
              assert input_data.shape[0] == n_samples
              assert input_data.shape[-1] == n_features
              has_classes = (
                  model_base.__class__.__name__ in ids_classifiers
              )
              if has_classes:
                  labels = np.tile(
                      range(n_classes), n_samples // n_classes + 1
                  )[:n_samples]
              else:
                  labels = np.tile(
                      labels, n_samples // labels.shape[0] + 1
                  )[:n_samples]
              model = clone(model_base)
              model.fit(input_data, labels)
              if (
                  n_components <= min(n_classes - 1, n_features)
                  and has_classes
              ):
                  model_other = clone(model_base).set_params(init="lda")
              elif n_components < min(n_features, n_samples):
                  model_other = clone(model_base).set_params(init="pca")
              else:
                  model_other = clone(model_base).set_params(
                      init="identity"
                  )
              model_other.fit(input_data, labels)
              assert_array_almost_equal(
                  model.components_, model_other.components_
              )
  
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 17 for calling a global function with example usage: test_auto_init_transformation(n_samples, n_features, n_classes, n_components, estimator, build_dataset) without return types