code: def test_array_like_inputs(
      estimator, build_dataset, with_preprocessor
  ):
      """Test that metric-learners can have as input (of all functions that are
      applied on data) any array-like object."""
      input_data, labels, preprocessor, X = build_dataset(
          with_preprocessor
      )
  
      # we subsample the data for the test to be more efficient
      input_data, _, labels, _ = train_test_split(
          input_data, labels, train_size=40, random_state=42
      )
      X = X[:10]
  
      estimator = clone(estimator)
      estimator.set_params(preprocessor=preprocessor)
      set_random_state(estimator)
      input_variants, label_variants = generate_array_like(
          input_data, labels
      )
      for input_variant in input_variants:
          for label_variant in label_variants:
              estimator.fit(
                  *remove_y(estimator, input_variant, label_variant)
              )
          if hasattr(estimator, "predict"):
              estimator.predict(input_variant)
          if hasattr(estimator, "predict_proba"):
              estimator.predict_proba(
                  input_variant
              )  # anticipation in case some
              # time we have that, or if ppl want to contribute with new algorithms
              # it will be checked automatically
          if hasattr(estimator, "decision_function"):
              estimator.decision_function(input_variant)
          if hasattr(estimator, "score"):
              for label_variant in label_variants:
                  estimator.score(
                      *remove_y(estimator, input_variant, label_variant)
                  )
  
      X_variants, _ = generate_array_like(X)
      for X_variant in X_variants:
          estimator.transform(X_variant)
  
      pairs = np.array([[X[0], X[1]], [X[0], X[2]]])
      pairs_variants, _ = generate_array_like(pairs)
  
      not_implemented_msg = ""
      # Todo in 0.7.0: Change 'not_implemented_msg' for the message that says
      # "This learner does not have pair_distance"
  
      for pairs_variant in pairs_variants:
          estimator.pair_score(
              pairs_variant
          )  # All learners have pair_score
  
          # But not all of them will have pair_distance
          try:
              estimator.pair_distance(pairs_variant)
          except Exception as raised_exception:
              assert (
                  raised_exception.value.args[0] == not_implemented_msg
              )
  
imports: import pytest
  import unittest
  from sklearn.utils.estimator_checks import check_estimator
  from sklearn.base import TransformerMixin
  from sklearn.pipeline import make_pipeline
  from sklearn.utils import check_random_state
  from metric_learn.sklearn_shims import assert_allclose_dense_sparse, set_random_state, _get_args, is_public_parameter, get_scorer
  from metric_learn import Covariance, LFDA, LMNN, MLKR, NCA, ITML_Supervised, LSML_Supervised, MMC_Supervised, RCA_Supervised, SDML_Supervised, SCML_Supervised
  from sklearn import clone
  import numpy
  from sklearn.model_selection import cross_val_score, cross_val_predict, train_test_split, KFold
  from test.test_utils import metric_learners, ids_metric_learners, mock_preprocessor, tuples_learners, ids_tuples_learners, pairs_learners, ids_pairs_learners, remove_y, metric_learners_pipeline, ids_metric_learners_pipeline
label_desc: Use image node_id 2 for calling a global function with example usage: test_array_like_inputs(estimator, build_dataset, with_preprocessor) without return types