code: def _approximate_shapley_values_via_permutation_sampling(
      set_func: Callable[[np.ndarray], Union[float, np.ndarray]],
      num_players: int,
      num_permutations: int,
      n_jobs: int,
      use_halton_sequence: bool = True,
  ) -> np.ndarray:
      """For more details about this approximation, see
      Strumbelj, E., Kononenko, I. (2014).
      Explaining prediction models and individual predictions with feature contributions.
      In Knowledge and information systems, 41(3):647–665
  
      When use_halton_sequence is true, a Sobol sequence is used to fill the sample space more uniformly than randomly
      generating a permutation. This can improve convergence seeing that the sampling aims at maximizing the information
      gain.
      """
      (
          full_subset_result,
          empty_subset_result,
      ) = _estimate_full_and_emtpy_subset_results(set_func, num_players)
  
      total_num_permutations = math.factorial(num_players)
      halton_generator = None
  
      num_permutations = min(total_num_permutations, num_permutations)
  
      if use_halton_sequence:
          halton_generator = Halton(
              num_players,
              seed=int(np.random.randint(np.iinfo(np.int32).max)),
          )
  
      subsets_to_evaluate = set()
      all_permutations = []
      for i in range(num_permutations):
          if halton_generator is None:
              permutation = np.random.choice(
                  num_players, num_players, replace=False
              )
          else:
              permutation = np.argsort(halton_generator.random(1))[0]
  
          all_permutations.append(permutation)
  
          subsets_to_evaluate.update(
              _create_index_order_and_subset_tuples(permutation)
          )
  
      with Parallel(n_jobs=n_jobs) as parallel:
          evaluated_subsets = _evaluate_set_function(
              set_func, subsets_to_evaluate, parallel
          )
  
      shapley_values = _estimate_shapley_values_of_permutation(
          all_permutations[0],
          evaluated_subsets,
          full_subset_result,
          empty_subset_result,
      )
      for i in range(1, len(all_permutations)):
          shapley_values += _estimate_shapley_values_of_permutation(
              all_permutations[i],
              evaluated_subsets,
              full_subset_result,
              empty_subset_result,
          )
  
      return shapley_values / len(all_permutations)
  
imports: import itertools
  import math
  from enum import Enum
  from typing import Callable, Dict, List, Optional, Set, Tuple, Union
  import numpy
  import scipy
  from joblib import Parallel, delayed
  from scipy.special import comb
  from scipy.stats._qmc import Halton
  from sklearn.linear_model import LinearRegression
  from tqdm import tqdm
  import dowhy.gcm.config
  from dowhy.gcm.util.general import set_random_seed
label_desc: Use image node_id 4 for calling a global function with example usage: _approximate_shapley_values_via_permutation_sampling(set_func, num_players, num_permutations, n_jobs, use_halton_sequence) and returns: unknown