code: def _approximate_shapley_values_via_least_squares_regression(
      set_func: Callable[[np.ndarray], Union[float, np.ndarray]],
      num_players: int,
      use_subset_approximation: bool,
      num_samples_for_approximation: int,
      n_jobs: int,
      full_and_empty_subset_weight: float = 10**20,
  ) -> np.ndarray:
      """For more details about this approximation, see Section 4.1.1 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.
      """
      if not use_subset_approximation:
          all_subsets, weights = _create_subsets_and_weights_exact(
              num_players, full_and_empty_subset_weight
          )
      else:
          (
              all_subsets,
              weights,
          ) = _create_subsets_and_weights_approximation(
              num_players,
              full_and_empty_subset_weight,
              num_samples_for_approximation,
          )
  
      def parallel_job(subset: np.ndarray, parallel_random_seed: int):
          set_random_seed(parallel_random_seed)
  
          return set_func(subset)
  
      with Parallel(n_jobs=n_jobs) as parallel:
          random_seeds = np.random.randint(
              np.iinfo(np.int32).max, size=len(all_subsets)
          )
          set_function_results = parallel(
              delayed(parallel_job)(subset, int(random_seed))
              for subset, random_seed in tqdm(
                  zip(all_subsets, random_seeds),
                  desc="Estimate shapley values as least squares solution",
                  position=0,
                  leave=True,
                  disable=not config.show_progress_bars,
              )
          )
  
      return (
          LinearRegression()
          .fit(
              all_subsets,
              np.array(set_function_results),
              sample_weight=weights,
          )
          .coef_
      )
  
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 3 for calling a global function with example usage: _approximate_shapley_values_via_least_squares_regression(set_func, num_players, use_subset_approximation, num_samples_for_approximation, n_jobs, full_and_empty_subset_weight) and returns: LinearRegression, set_func