code: def test_iforest_works(setup, contamination):
      rs = np.random.RandomState(0)
      # toy sample (the last two samples are outliers)
      raw = np.array(
          [
              [-2, -1],
              [-1, -1],
              [-1, -2],
              [1, 1],
              [1, 2],
              [2, 1],
              [6, 3],
              [-4, 7],
          ]
      )
      t = mt.tensor(raw, chunk_size=4)
  
      # Test IsolationForest
      clf = IsolationForest(
          random_state=rs, contamination=contamination
      )
      clf.fit(t)
      decision_func = -clf.decision_function(t).execute().fetch()
      pred = clf.predict(t).execute().fetch()
      # assert detect outliers:
      assert np.min(decision_func[-2:]) > np.max(decision_func[:-2])
      np.testing.assert_array_equal(pred, 6 * [1] + 2 * [-1])
  
file_path: mars/mars/learn/ensemble/tests/test_iforest.py
imports: import numpy
  import pytest
  from sklearn.datasets import load_iris
  from ....None import tensor
  from .._iforest import IsolationForest
label_desc: Use image node_id 2 for calling a global function with example usage: test_iforest_works(setup, contamination) without return types