class_docstr: Class for creating and modifying the causal graph.
  
  Accepts a networkx DiGraph, a :py:class:`ProbabilisticCausalModel <dowhy.gcm.ProbabilisticCausalModel`, a graph string (or a text file) in gml format (preferred) or dot format. Graphviz-like attributes can be set for edges and nodes. E.g. style="dashed" as an edge attribute ensures that the edge is drawn with a dashed line.
  
   If a graph string is not given, names of treatment, outcome, and confounders, instruments and effect modifiers (if any) can be provided to create the graph.
class_docstr_tok: ["Class","for","creating","and","modifying","the","causal","graph",".","Accepts","a","networkx","DiGraph",",","a",":","py",":","class",":","`","ProbabilisticCausalModel","<","dowhy.gcm.ProbabilisticCausalModel","`",",","a","graph","string","(","or","a","text","file",")","in","gml","format","(","preferred",")","or","dot","format",".","Graphviz-like","attributes","can","be","set","for","edges","and","nodes",".","E.g",".","style=","''","dashed","''","as","an","edge","attribute","ensures","that","the","edge","is","drawn","with","a","dashed","line",".","If","a","graph","string","is","not","given",",","names","of","treatment",",","outcome",",","and","confounders",",","instruments","and","effect","modifiers","(","if","any",")","can","be","provided","to","create","the","graph","."]
docstr: Check if candidate nodes are valid mediators for set of treatments, nodes1 to set of outcomes, nodes2.
docstr_tok: ["Check","if","candidate","nodes","are","valid","mediators","for","set","of","treatments",",","nodes1","to","set","of","outcomes",",","nodes2","."]
code: def check_valid_mediation_set(
      self, 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 = self.get_all_directed_paths(nodes1, nodes2)
  
      is_mediator = any(
          [
              self.is_blocked(path, candidate_nodes)
              for path in mediation_paths
          ]
      )
      return is_mediator
  
imports: import itertools
  import logging
  import re
  import networkx
  from dowhy.gcm.causal_models import ProbabilisticCausalModel
  from dowhy.utils.api import parse_state
  from dowhy.utils.graph_operations import daggity_to_dot
  from dowhy.utils.plotting import plot
label_desc: Use image node_id 27 for calling the CausalGraph obj's underlying member method code with example usage: obj.check_valid_mediation_set(nodes1, nodes2, candidate_nodes, mediation_paths) and returns: is_mediator