code: def test_predict_only_one_or_minus_one(
      estimator, build_dataset, with_preprocessor
  ):
      """Test that all predicted values are either +1 or -1"""
      input_data, labels, preprocessor, _ = build_dataset(
          with_preprocessor
      )
      estimator = clone(estimator)
      estimator.set_params(preprocessor=preprocessor)
      set_random_state(estimator)
      pairs_train, pairs_test, y_train, y_test = train_test_split(
          input_data, labels
      )
      estimator.fit(pairs_train, y_train)
      predictions = estimator.predict(pairs_test)
      not_valid = [e for e in predictions if e not in [-1, 1]]
      assert len(not_valid) == 0
  
imports: from functools import partial
  import pytest
  from numpy.testing import assert_array_equal
  from scipy.spatial.distance import euclidean
  from metric_learn.base_metric import _PairsClassifierMixin, MahalanobisMixin
  from sklearn.exceptions import NotFittedError
  from sklearn.metrics import f1_score, accuracy_score, fbeta_score, precision_score
  from sklearn.model_selection import train_test_split
  from test.test_utils import pairs_learners, ids_pairs_learners
  from metric_learn.sklearn_shims import set_random_state
  from sklearn import clone
  import numpy
  from itertools import product
label_desc: Use image node_id 1 for calling a global function with example usage: test_predict_only_one_or_minus_one(estimator, build_dataset, with_preprocessor) without return types