code: def mc_shapley(
      coalition: list,
      data: Data,
      value_func: str,
      subgraph_building_method="zero_filling",
      sample_num=1000,
  ) -> float:
      """monte carlo sampling approximation of the shapley value"""
      subset_build_func = get_graph_build_func(subgraph_building_method)
  
      num_nodes = data.num_nodes
      node_indices = np.arange(num_nodes)
      coalition_placeholder = num_nodes
      set_exclude_masks = []
      set_include_masks = []
  
      for example_idx in range(sample_num):
          subset_nodes_from = [
              node for node in node_indices if node not in coalition
          ]
          random_nodes_permutation = np.array(
              subset_nodes_from + [coalition_placeholder]
          )
          random_nodes_permutation = np.random.permutation(
              random_nodes_permutation
          )
          split_idx = np.where(
              random_nodes_permutation == coalition_placeholder
          )[0][0]
          selected_nodes = random_nodes_permutation[:split_idx]
          set_exclude_mask = np.zeros(num_nodes)
          set_exclude_mask[selected_nodes] = 1.0
          set_include_mask = set_exclude_mask.copy()
          set_include_mask[coalition] = 1.0
  
          set_exclude_masks.append(set_exclude_mask)
          set_include_masks.append(set_include_mask)
  
      exclude_mask = np.stack(set_exclude_masks, axis=0)
      include_mask = np.stack(set_include_masks, axis=0)
      marginal_contributions = marginal_contribution(
          data,
          exclude_mask,
          include_mask,
          value_func,
          subset_build_func,
      )
      mc_shapley_value = marginal_contributions.mean().item()
  
      return mc_shapley_value
  
imports: import copy
  import torch
  import numpy
  from scipy.special import comb
  from itertools import combinations
  import torch.nn.functional
  from torch_geometric.utils import to_networkx
  from torch_geometric.data import Data, Batch, Dataset
  from torch_geometric.loader import DataLoader
label_desc: Use image node_id 8 for calling a global function with example usage: mc_shapley(coalition, data, value_func, subgraph_building_method, sample_num) and returns: mc_shapley_value