code: def check_valid_mediation_set(
      graph: nx.DiGraph,
      nodes1,
      nodes2,
      candidate_nodes,
      mediation_paths=None,
  ):
      """Check if candidate nodes are valid mediators for set of treatments, nodes1 to set of outcomes, nodes2."""
      if mediation_paths is None:
          mediation_paths = get_all_directed_paths(
              graph, nodes1, nodes2
          )
  
      is_mediator = any(
          [
              is_blocked(graph, path, candidate_nodes)
              for path in mediation_paths
          ]
      )
      return is_mediator
  
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 17 for calling a global function with example usage: check_valid_mediation_set(graph, nodes1, nodes2, candidate_nodes, mediation_paths) and returns: is_mediator