code: def check_valid_backdoor_set(
      graph: nx.DiGraph,
      nodes1,
      nodes2,
      nodes3,
      backdoor_paths=None,
      new_graph: nx.DiGraph = None,
      dseparation_algo="default",
  ):
      """Assume that the first parameter (nodes1) is the treatment,
      the second is the outcome, and the third is the candidate backdoor set
      """
      # also return the number of backdoor paths blocked by observed nodes
      if dseparation_algo == "default":
          if new_graph is None:
              # Assume that nodes1 is the treatment
              new_graph = do_surgery(
                  graph, nodes1, remove_outgoing_edges=True
              )
  
          dseparated = nx.algorithms.d_separated(
              new_graph, set(nodes1), set(nodes2), set(nodes3)
          )
      elif dseparation_algo == "naive":
          # ignores new_graph parameter, always uses self._graph
          if backdoor_paths is None:
              backdoor_paths = get_backdoor_paths(graph, nodes1, nodes2)
          dseparated = all(
              [
                  is_blocked(graph, path, nodes3)
                  for path in backdoor_paths
              ]
          )
      else:
          raise ValueError(
              f"{dseparation_algo} method for d-separation not supported."
          )
      return {"is_dseparated": 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 6 for calling a global function with example usage: check_valid_backdoor_set(graph, nodes1, nodes2, nodes3, backdoor_paths, new_graph, dseparation_algo) and returns: dict