class_docstr: Represents a probabilistic graphical causal model, i.e. it combines a graphical representation of causal
  causal relationships and corresponding causal mechanism for each node describing the data generation process. The
  causal mechanisms can be any general stochastic models.
class_docstr_tok: ["Represents","a","probabilistic","graphical","causal","model",",","i.e",".","it","combines","a","graphical","representation","of","causal","causal","relationships","and","corresponding","causal","mechanism","for","each","node","describing","the","data","generation","process",".","The","causal","mechanisms","can","be","any","general","stochastic","models","."]
docstr: Assigns the generative causal model of node in the causal graph.
  
  :param node: Target node whose causal model is to be assigned.
  :param mechanism: Causal mechanism to be assigned. A root node must be a
                    :class:`~dowhy.gcm.graph.StochasticModel`, whereas a non-root node must be a
                    :class:`~dowhy.gcm.graph.ConditionalStochasticModel`.
docstr_tok: ["Assigns","the","generative","causal","model","of","node","in","the","causal","graph",".",":","param","node",":","Target","node","whose","causal","model","is","to","be","assigned",".",":","param","mechanism",":","Causal","mechanism","to","be","assigned",".","A","root","node","must","be","a",":","class",":","`","~dowhy.gcm.graph.StochasticModel","`",",","whereas","a","non-root","node","must","be","a",":","class",":","`","~dowhy.gcm.graph.ConditionalStochasticModel","`","."]
code: def set_causal_mechanism(
      self,
      node: Any,
      mechanism: Union[StochasticModel, ConditionalStochasticModel],
  ) -> None:
      """Assigns the generative causal model of node in the causal graph.
  
      :param node: Target node whose causal model is to be assigned.
      :param mechanism: Causal mechanism to be assigned. A root node must be a
                        :class:`~dowhy.gcm.graph.StochasticModel`, whereas a non-root node must be a
                        :class:`~dowhy.gcm.graph.ConditionalStochasticModel`.
      """
      if node not in self.graph.nodes:
          raise ValueError(
              "Node %s can not be found in the given graph!" % node
          )
      self.graph.nodes[node][CAUSAL_MECHANISM] = mechanism
  
imports: from typing import Any, Callable, Optional, Union
  import networkx
  from dowhy.gcm.causal_mechanisms import ConditionalStochasticModel, FunctionalCausalModel, InvertibleFunctionalCausalModel, StochasticModel
  from dowhy.graph import DirectedGraph, HasNodes, get_ordered_predecessors, is_root_node, validate_acyclic, validate_node_in_graph
label_desc: Use image node_id 2 for calling the ProbabilisticCausalModel obj's underlying member method code with example usage: obj.set_causal_mechanism(node, mechanism) without return types