code: def remove_resample(
      nmask,
      X_train,
      y_train,
      X_test,
      y_test,
      attr_test,
      model_generator,
      metric,
      trained_model,
      random_state,
  ):
      """The model is reevaluated for each test sample with the important features set to resample background values."""
  
      X_train, X_test = to_array(X_train, X_test)
  
      # how many features to mask
      assert X_train.shape[1] == X_test.shape[1]
  
      # how many samples to take
      nsamples = 100
  
      # keep nkeep top features for each test explanation
      N, M = X_test.shape
      X_test_tmp = np.tile(X_test, [1, nsamples]).reshape(
          nsamples * N, M
      )
      tie_breaking_noise = const_rand(M) * 1e-6
      inds = sklearn.utils.resample(
          np.arange(N), n_samples=nsamples, random_state=random_state
      )
      for i in range(N):
          if nmask[i] > 0:
              ordering = np.argsort(
                  -attr_test[i, :] + tie_breaking_noise
              )
              X_test_tmp[
                  i * nsamples : (i + 1) * nsamples,
                  ordering[: nmask[i]],
              ] = X_train[inds, :][:, ordering[: nmask[i]]]
  
      yp_masked_test = trained_model.predict(X_test_tmp)
      yp_masked_test = np.reshape(yp_masked_test, (N, nsamples)).mean(
          1
      )  # take the mean output over all samples
  
      return metric(y_test, yp_masked_test)
  
file_path: shap/shap/benchmark/measures.py
imports: import warnings
  import numpy
  import pandas
  import sklearn.utils
  from tqdm.auto import tqdm
label_desc: Use image node_id 4 for calling a global function with example usage: remove_resample(nmask, X_train, y_train, X_test, y_test, attr_test, model_generator, metric, trained_model, random_state) and returns: metric