code: def check_valid_frontdoor_set(
      graph: nx.DiGraph,
      nodes1,
      nodes2,
      candidate_nodes,
      frontdoor_paths=None,
      new_graph: nx.DiGraph = None,
      dseparation_algo="default",
  ):
      """Check if valid the frontdoor variables for set of treatments, nodes1 to set of outcomes, nodes2."""
      # Condition 1: node 1 ---> node 2 is intercepted by candidate_nodes
      if dseparation_algo == "default":
          if new_graph is None:
              new_graph = graph
          dseparated = nx.algorithms.d_separated(
              new_graph, set(nodes1), set(nodes2), set(candidate_nodes)
          )
      elif dseparation_algo == "naive":
          if frontdoor_paths is None:
              frontdoor_paths = get_all_directed_paths(
                  graph, nodes1, nodes2
              )
  
          dseparated = all(
              [
                  is_blocked(graph, path, candidate_nodes)
                  for path in frontdoor_paths
              ]
          )
      else:
          raise ValueError(
              f"{dseparation_algo} method for d-separation not supported."
          )
      return dseparated
  
imports: import itertools
  import logging
  import re
  from abc import abstractmethod
  from typing import Any, List, Protocol
  import networkx
  from networkx.algorithms.dag import has_cycle
  from dowhy.utils.api import parse_state
  from dowhy.utils.graph_operations import daggity_to_dot
label_desc: Use image node_id 14 for calling a global function with example usage: check_valid_frontdoor_set(graph, nodes1, nodes2, candidate_nodes, frontdoor_paths, new_graph, dseparation_algo) and returns: dseparated