code: def calculate_variable_importance(
      explainer,
      type,
      loss_function,
      variables,
      N,
      B,
      label,
      processes,
      keep_raw_permutations,
      random_state,
  ):
      if processes == 1:
          result = [None] * B
          for i in range(B):
              result[i] = loss_after_permutation(
                  explainer.data,
                  explainer.y,
                  explainer.model,
                  explainer.predict_function,
                  loss_function,
                  variables,
                  N,
                  np.random,
              )
      else:
          # Create number generator for each iteration
          ss = SeedSequence(random_state)
          generators = [default_rng(s) for s in ss.spawn(B)]
          pool = mp.get_context("spawn").Pool(processes)
          result = pool.starmap_async(
              loss_after_permutation,
              [
                  (
                      explainer.data,
                      explainer.y,
                      explainer.model,
                      explainer.predict_function,
                      loss_function,
                      variables,
                      N,
                      generators[i],
                  )
                  for i in range(B)
              ],
          ).get()
          pool.close()
  
      raw = pd.concat(result, sort=True)
      result = raw.mean().sort_values().reset_index()
      result["label"] = label
  
      result.rename(
          columns={0: "dropout_loss", "index": "variable"}, inplace=True
      )
  
      if type == "ratio":
          result.loc[:, "dropout_loss"] = (
              result.loc[:, "dropout_loss"]
              / result.loc[
                  result.variable == "_full_model_", "dropout_loss"
              ].values
          )
  
      if type == "difference":
          result.loc[:, "dropout_loss"] = (
              result.loc[:, "dropout_loss"]
              - result.loc[
                  result.variable == "_full_model_", "dropout_loss"
              ].values
          )
  
      raw_permutations = (
          raw.reset_index(drop=True) if keep_raw_permutations else None
      )
  
      return result, raw_permutations
  
imports: import multiprocessing
  from numpy.random import SeedSequence, default_rng
  import numpy
  import pandas
label_desc: Use image node_id 1 for calling a global function with example usage: calculate_variable_importance(explainer, type, loss_function, variables, N, B, label, processes, keep_raw_permutations, random_state) and returns: result,  raw_permutations