code: def mc_l_shapley(
      coalition: list,
      data: Data,
      local_radius: int,
      value_func: str,
      subgraph_building_method="zero_filling",
      sample_num=1000,
  ) -> float:
      """monte carlo sampling approximation of the l_shapley value"""
      graph = to_networkx(data)
      num_nodes = graph.number_of_nodes()
      subgraph_build_func = get_graph_build_func(
          subgraph_building_method
      )
  
      local_region = copy.copy(coalition)
      for k in range(local_radius - 1):
          k_neiborhoood = []
          for node in local_region:
              k_neiborhoood += list(graph.neighbors(node))
          local_region += k_neiborhoood
          local_region = list(set(local_region))
  
      coalition_placeholder = num_nodes
      set_exclude_masks = []
      set_include_masks = []
      for example_idx in range(sample_num):
          subset_nodes_from = [
              node for node in local_region 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.ones(num_nodes)
          set_exclude_mask[local_region] = 0.0
          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,
          subgraph_build_func,
      )
  
      mc_l_shapley_value = (marginal_contributions).mean().item()
      return mc_l_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 9 for calling a global function with example usage: mc_l_shapley(coalition, data, local_radius, value_func, subgraph_building_method, sample_num) and returns: mc_l_shapley_value