code: def _estimate_shapley_values_exact(
      set_func: Callable[[np.ndarray], Union[float, np.ndarray]],
      num_players: int,
      n_jobs: int,
  ) -> np.ndarray:
      """Following Eq. (2) in
      Janzing, D., Minorics, L., & Bloebaum, P. (2020).
      Feature relevance quantification in explainable AI: A causal problem.
      In International Conference on Artificial Intelligence and Statistics (pp. 2907-2916). PMLR.
      """
      all_subsets = [
          tuple(subset)
          for subset in itertools.product([0, 1], repeat=num_players)
      ]
  
      with Parallel(n_jobs=n_jobs) as parallel:
          subset_to_result_map = _evaluate_set_function(
              set_func, all_subsets, parallel
          )
  
      def compute_subset_weight(length: int) -> float:
          return 1 / (num_players * comb(num_players - 1, length))
  
      subset_weight_cache = {}
  
      shapley_values = [None] * num_players
      subsets_missing_one_player = np.array(
          list(itertools.product([0, 1], repeat=num_players - 1))
      )
      for player_index in range(num_players):
          subsets_with_player = [
              tuple(subset)
              for subset in np.insert(
                  subsets_missing_one_player, player_index, 1, axis=1
              )
          ]
          subsets_without_player = [
              tuple(subset)
              for subset in np.insert(
                  subsets_missing_one_player, player_index, 0, axis=1
              )
          ]
  
          for i in range(len(subsets_with_player)):
              subset_length = int(np.sum(subsets_without_player[i]))
              if subset_length not in subset_weight_cache:
                  subset_weight_cache[
                      subset_length
                  ] = compute_subset_weight(subset_length)
  
              weighted_diff = subset_weight_cache[subset_length] * (
                  subset_to_result_map[subsets_with_player[i]]
                  - subset_to_result_map[subsets_without_player[i]]
              )
              # For estimating Shapley values for multiple samples (e.g. in feature relevance) and the number of samples
              # is unknown beforehand.
              if shapley_values[player_index] is None:
                  shapley_values[player_index] = weighted_diff
              else:
                  shapley_values[player_index] += weighted_diff
  
      return np.array(shapley_values).T
  
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 2 for calling a global function with example usage: _estimate_shapley_values_exact(set_func, num_players, n_jobs) and returns: np, unknown