code: def permutation_importances_raw(
      rf, X_train, y_train, metric, n_samples=5000
  ):
      """
      Return array of importances from pre-fit rf; metric is function
      that measures accuracy or R^2 or similar. This function
      works for regressors and classifiers.
      """
      X_sample, y_sample, _ = sample(X_train, y_train, n_samples)
  
      if not hasattr(rf, "estimators_"):
          rf.fit(X_sample, y_sample)
  
      baseline = metric(rf, X_sample, y_sample)
      X_train = X_sample.copy(deep=False)  # shallow copy
      y_train = y_sample
      imp = []
      for col in X_train.columns:
          save = X_train[col].copy()
          X_train[col] = np.random.permutation(X_train[col])
          m = metric(rf, X_train, y_train)
          X_train[col] = save
          drop_in_metric = baseline - m
          imp.append(drop_in_metric)
      return np.array(imp)
  
imports: import pandas
  import numpy
  import matplotlib.pyplot
  import sklearn
  from sklearn.ensemble import RandomForestClassifier
  from sklearn.ensemble import RandomForestRegressor
  from distutils.version import LooseVersion
  from sklearn.model_selection import cross_val_score
  from sklearn.base import clone
  from sklearn.metrics import r2_score
  from sklearn.metrics import f1_score
  from sklearn.preprocessing import LabelEncoder
  from scipy import stats
  from pandas.api.types import is_numeric_dtype
  from matplotlib.colors import ListedColormap
  from matplotlib.ticker import FormatStrFormatter
  from copy import copy
  import warnings
  import tempfile
  from os import getpid, makedirs
label_desc: Use image node_id 10 for calling a global function with example usage: permutation_importances_raw(rf, X_train, y_train, metric, n_samples) and returns: np