code: def validate_causal_model_assignment(
      causal_graph: DirectedGraph, target_node: Any
  ) -> None:
      validate_node_has_causal_model(causal_graph, target_node)
  
      causal_model = causal_graph.nodes[target_node][CAUSAL_MECHANISM]
  
      if is_root_node(causal_graph, target_node):
          if not isinstance(causal_model, StochasticModel):
              raise RuntimeError(
                  "Node %s is a root node and, thus, requires a StochasticModel, "
                  "but a %s was found!" % (target_node, causal_model)
              )
      elif not isinstance(causal_model, ConditionalStochasticModel):
          raise RuntimeError(
              "Node %s has parents and, thus, requires a ConditionalStochasticModel, "
              "but a %s was found!" % (target_node, causal_model)
          )
  
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 1 for calling a global function with example usage: validate_causal_model_assignment(causal_graph, target_node) without return types