code: def test_compute_estimate(n_repeats, mocker):
      """Test if the estimate computation generates the expected samples and if the construction of the
      sample is correct."""
      X = np.array([[1, 6], [2, 7], [3, 8], [4, 9], [5, 10]])
      y = np.array([1, 2, 3, 4, 5])
      pfi = PermutationImportance(
          predictor=lambda x: x[:, 0],
          score_fns={"accuracy": accuracy_score},
      )
  
      mock = mocker.patch.object(
          PermutationImportance,
          "_compute_metrics",
          wraps=pfi._compute_metrics,
      )
      feature_importances = pfi._compute_estimate(
          X=X,
          y=y,
          kind="difference",
          n_repeats=n_repeats,
          sample_weight=None,
          features=0,
          loss_orig={},
          score_orig={"accuracy": [1.0]},
      )
  
      for _, kwargs in mock.call_args_list:
          y_call, y_hat_call = kwargs["y"], kwargs["y_hat"]
          assert len(y_call) == len(y_hat_call)
          assert len(y_call) % 2 == 0
  
          start, middle, end = 0, len(y_call) // 2, len(y_call)
          fh, sh = np.s_[start:middle], np.s_[middle:end]
          assert np.allclose(y_call[fh], y_hat_call[sh])
          assert np.allclose(y_call[sh], y_hat_call[fh])
          assert np.all(np.isin(y_call, y))
  
      assert mock.call_count == 2 * n_repeats
      assert np.isclose(feature_importances["accuracy"]["mean"], 1)
      assert np.isclose(feature_importances["accuracy"]["std"], 0)
      assert (
          len(feature_importances["accuracy"]["samples"]) == n_repeats
      )
      assert np.allclose(feature_importances["accuracy"]["samples"], 1)
  
imports: import re
  from copy import deepcopy
  import matplotlib.pyplot
  import numpy
  import pytest
  from pytest_lazyfixture import lazy_fixture
  from sklearn.metrics import accuracy_score, f1_score, max_error
  from alibi.api.defaults import DEFAULT_DATA_PERMUTATION_IMPORTANCE, DEFAULT_META_PERMUTATION_IMPORTANCE
  from alibi.api.interfaces import Explanation
  from alibi.explainers import PermutationImportance, plot_permutation_importance
label_desc: Use image node_id 14 for calling a global function with example usage: test_compute_estimate(n_repeats, mocker) without return types