code: def validate_tpa(
      causal_graph: DirectedGraph,
      causal_graph_reference: DirectedGraph,
      include_unconditional: bool = True,
  ) -> Dict[str, int]:
      """
      Graphical criterion to evaluate which pairwise parental d-separations (parental triples) in `causal_graph` are
      violated, assuming `causal_graph_reference` is the ground truth graph. If none are violated, then both graphs lie
      in the same Markov equivalence class.
      Specifically we test:
          X _|_G' Y | Z and X _/|_G Y | Z for Y \in ND{X}^G', Z = PA{X}^G
  
      :param causal_graph: Causal graph for which to evaluate parental d-separations (G')
      :param causal_graph_reference: Causal graph where we test if d-separation holds (G)
      :param include_unconditional: Test also unconditional independencies of root nodes.
      :return: Validation summary with number of d-separations implied by `causal_graph` and number of times these are
          violated in the graph `causal_graph_reference`.
      """
      validation_summary = {
          FalsifyConst.METHOD: FalsifyConst.VALIDATE_TPA,
          FalsifyConst.N_VIOLATIONS: 0,
          FalsifyConst.N_TESTS: 0,
      }
  
      triples = _get_parental_triples(
          causal_graph, include_unconditional
      )
      for node, non_desc, parents in triples:
          validation_summary[FalsifyConst.N_TESTS] += 1
          if not nx.d_separated(
              causal_graph_reference, {node}, {non_desc}, set(parents)
          ):
              validation_summary[FalsifyConst.N_VIOLATIONS] += 1
      return validation_summary
  
imports: import warnings
  from dataclasses import dataclass, field
  from enum import Enum, auto
  from functools import partial
  from inspect import getfullargspec
  from itertools import permutations
  from typing import Any, Callable, Dict, FrozenSet, List, Optional, Set, Tuple, Union
  import matplotlib.colors
  import matplotlib.pyplot
  import networkx
  import numpy
  import pandas
  from joblib import Parallel, delayed
  from tqdm import tqdm
  import dowhy.gcm.config
  from dowhy.gcm.independence_test import kernel_based
  from dowhy.gcm.util import plot
  from dowhy.gcm.util.general import set_random_seed
  from dowhy.graph import DirectedGraph, get_ordered_predecessors
label_desc: Use image node_id 2 for calling a global function with example usage: validate_tpa(causal_graph, causal_graph_reference, include_unconditional) and returns: validation_summary