code: def fit_causal_model_of_target(
      causal_model: ProbabilisticCausalModel,
      target_node: Any,
      training_data: pd.DataFrame,
  ) -> None:
      """Fits only the causal mechanism of the given target node based on the training data.
  
      :param causal_model: The causal model containing the target node.
      :param target_node: Target node for which the mechanism is fitted.
      :param training_data: Training data for fitting the causal mechanism.
      :return: None
      """
      validate_causal_model_assignment(causal_model.graph, target_node)
  
      if is_root_node(causal_model.graph, target_node):
          causal_model.causal_mechanism(target_node).fit(
              X=training_data[target_node].to_numpy()
          )
      else:
          causal_model.causal_mechanism(target_node).fit(
              X=training_data[
                  get_ordered_predecessors(
                      causal_model.graph, target_node
                  )
              ].to_numpy(),
              Y=training_data[target_node].to_numpy(),
          )
  
      # To be able to validate that the graph structure did not change between fitting and causal query, we store the
      # parents of a node during fit. That way, before sampling, we can verify the parents are still the same. While
      # this would automatically fail when the number of parents is different, there are other more subtle cases,
      # where the number is still the same, but it's different parents, and therefore different data. That would yield
      # wrong results, but would not fail.
      causal_model.graph.nodes[target_node][
          PARENTS_DURING_FIT
      ] = get_ordered_predecessors(causal_model.graph, target_node)
  
file_path: dowhy/dowhy/gcm/fitting_sampling.py
imports: from typing import Any
  import networkx
  import numpy
  import pandas
  from tqdm import tqdm
  from dowhy.gcm import config
  from dowhy.gcm.causal_models import PARENTS_DURING_FIT, ProbabilisticCausalModel, validate_causal_dag, validate_causal_model_assignment
  from dowhy.graph import get_ordered_predecessors, is_root_node
label_desc: Use image node_id 2 for calling a global function with example usage: fit_causal_model_of_target(causal_model, target_node, training_data) without return types