code: def arrow_strength(
      causal_model: ProbabilisticCausalModel,
      target_node: Any,
      parent_samples: Optional[pd.DataFrame] = None,
      num_samples_conditional: int = 2000,
      max_num_runs: int = 5000,
      tolerance: float = 0.01,
      n_jobs: int = -1,
      difference_estimation_func: Optional[
          Callable[[np.ndarray, np.ndarray], Union[np.ndarray, float]]
      ] = None,
  ) -> Dict[Tuple[Any, Any], float]:
      """Computes the causal strength of each edge directed to the target node.
      The strength of an edge is quantified in terms of distance between conditional distributions of the target node in
      the original graph and the imputed graph wherein the edge has been removed and the target node is fed a random
      permutation of the observations of the source node. For more scientific details behind this API, please refer to
      the research paper below.
  
      **Research Paper**:
      Dominik Janzing, David Balduzzi, Moritz Grosse-Wentrup, Bernhard Schölkopf. *Quantifying Causal Influences*. The
      Annals of Statistics, Vol. 41, No. 5, 2324-2358, 2013.
  
      :param causal_model: The probabilistic causal model for whose target node we compute the strength of incoming
                           edges for.
      :param target_node: The target node whose incoming edges' strength is to be computed.
      :param parent_samples: Optional samples from the parents of the target_node. If None are given, they are generated
                             based on the provided causal model. Providing observational data can help to mitigate
                             misspecifications in the graph, such as missing interactions between root nodes or
                             confounders.
      :param num_samples_conditional: Sample size to use for estimating the distance between distributions. The more
                                      more samples, the higher the accuracy.
      :param max_num_runs: The maximum number of times to resample and estimate the strength to report the average
                           strength.
      :param tolerance: If the percentage change in the estimated strength between two consecutive runs falls below the
                        specified tolerance, the algorithm will terminate before reaching the maximum number of runs.
                        A value of 0.01 would indicate a change of less than 1%. However, in order to minimize the impact
                        of randomness, there must be at least three consecutive runs where the change is below the
                        threshold.
      :param n_jobs: The number of jobs to run in parallel. Set it to -1 to use all processors.
      :param difference_estimation_func: Optional: How to measure the distance between two distributions. By default,
                                         the difference of the variance is estimated for a continuous target node
                                         and the KL divergence for a categorical target node.
      :return: Causal strength of each edge.
      """
      if target_node not in causal_model.graph.nodes:
          raise ValueError(
              "Target node %s can not be found in given graph!"
              % target_node
          )
      if is_root_node(causal_model.graph, target_node):
          raise ValueError(
              "Target node %s is a root node, but it requires to have ancestors!"
              % target_node
          )
  
      # Creating a smaller subgraph, which only contains upstream nodes that are connected to the target node.
      sub_causal_model = ProbabilisticCausalModel(
          node_connected_subgraph_view(causal_model.graph, target_node)
      )
      validate_node(sub_causal_model.graph, target_node)
  
      ordered_predecessors = get_ordered_predecessors(
          sub_causal_model.graph, target_node
      )
  
      if parent_samples is None:
          parent_samples = draw_samples(
              sub_causal_model, num_samples_conditional * 20
          )[ordered_predecessors]
  
      direct_influences = arrow_strength_of_model(
          sub_causal_model.causal_mechanism(target_node),
          parent_samples[ordered_predecessors].to_numpy(),
          num_samples_from_conditional=num_samples_conditional,
          max_num_runs=max_num_runs,
          tolerance=tolerance,
          n_jobs=n_jobs,
          difference_estimation_func=difference_estimation_func,
      )
      return {
          (predecessor, target_node): direct_influences[i]
          for i, predecessor in enumerate(ordered_predecessors)
      }
  
imports: import logging
  import warnings
  from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union, cast
  import numpy
  import pandas
  from joblib import Parallel, delayed
  from numpy.matlib import repmat
  import dowhy.gcm.auto
  from dowhy.gcm import feature_relevance_sample
  from dowhy.gcm._noise import compute_data_from_noise, compute_noise_from_data, noise_samples_of_ancestors
  from dowhy.gcm.causal_mechanisms import ClassifierFCM, ConditionalStochasticModel, ProbabilityEstimatorModel
  from dowhy.gcm.causal_models import InvertibleStructuralCausalModel, ProbabilisticCausalModel, StructuralCausalModel, validate_causal_dag, validate_node
  from dowhy.gcm.divergence import estimate_kl_divergence_of_probabilities
  from dowhy.gcm.fitting_sampling import draw_samples
  from dowhy.gcm.ml import ClassificationModel, PredictionModel
  from dowhy.gcm.shapley import ShapleyConfig, estimate_shapley_values
  from dowhy.gcm.stats import marginal_expectation
  from dowhy.gcm.uncertainty import estimate_entropy_of_probabilities, estimate_variance
  from dowhy.gcm.util.general import has_categorical, is_categorical, means_difference, set_random_seed, shape_into_2d
  from dowhy.graph import get_ordered_predecessors, is_root_node, node_connected_subgraph_view
label_desc: Use image node_id 1 for calling a global function with example usage: arrow_strength(causal_model, target_node, parent_samples, num_samples_conditional, max_num_runs, tolerance, n_jobs, difference_estimation_func) and returns: unknown