code: def test_iforest_works(contamination, global_random_seed):
      # toy sample (the last two samples are outliers)
      X = [
          [-2, -1],
          [-1, -1],
          [-1, -2],
          [1, 1],
          [1, 2],
          [2, 1],
          [7, 4],
          [-5, 9],
      ]
  
      # Test IsolationForest
      clf = IsolationForest(
          random_state=global_random_seed, contamination=contamination
      )
      clf.fit(X)
      decision_func = -clf.decision_function(X)
      pred = clf.predict(X)
      # assert detect outliers:
      assert np.min(decision_func[-2:]) > np.max(decision_func[:-2])
      assert_array_equal(pred, 6 * [1] + 2 * [-1])
  
imports: import warnings
  from unittest.mock import Mock, patch
  import numpy
  import pytest
  from sklearn.datasets import load_diabetes, load_iris, make_classification
  from sklearn.ensemble import IsolationForest
  from sklearn.ensemble._iforest import _average_path_length
  from sklearn.metrics import roc_auc_score
  from sklearn.model_selection import ParameterGrid, train_test_split
  from sklearn.utils import check_random_state
  from sklearn.utils._testing import assert_allclose, assert_array_almost_equal, assert_array_equal, ignore_warnings
  from sklearn.utils.fixes import CSC_CONTAINERS, CSR_CONTAINERS
label_desc: Use image node_id 8 for calling a global function with example usage: test_iforest_works(contamination, global_random_seed) without return types