code: def interventional_samples(
      causal_model: ProbabilisticCausalModel,
      interventions: Dict[
          Any, Callable[[np.ndarray], Union[float, np.ndarray]]
      ],
      observed_data: Optional[pd.DataFrame] = None,
      num_samples_to_draw: Optional[int] = None,
  ) -> pd.DataFrame:
      """Performs intervention on nodes in the causal graph.
  
      :param causal_model: The probabilistic causal model we perform this intervention on .
      :param interventions: Dictionary containing the interventions we want to perform, keyed by node name. An
                            intervention is a function that takes a value as input and returns another value.
                            For example, `{'X': lambda x: 2}` mimics the atomic intervention *do(X:=2)*.
                            A soft intervention can be formulated as `{'X': lambda x: 0.2 * x}`.
      :param observed_data: Optionally, data on which to perform interventions. If None are given, data is generated based
                            on the generative models.
      :param num_samples_to_draw: Sample size to draw from the interventional distribution.
      :return: Samples from the interventional distribution.
      """
      validate_causal_dag(causal_model.graph)
      for node in interventions:
          validate_node_in_graph(causal_model.graph, node)
  
      if observed_data is None and num_samples_to_draw is None:
          raise ValueError(
              "Either observed_samples or num_samples_to_draw need to be set!"
          )
      if observed_data is not None and num_samples_to_draw is not None:
          raise ValueError(
              "Either observed_samples or num_samples_to_draw need to be set, not both!"
          )
  
      if num_samples_to_draw is not None:
          observed_data = draw_samples(
              causal_model, num_samples_to_draw
          )
  
      return _interventional_samples(
          causal_model, observed_data, interventions
      )
  
file_path: dowhy/dowhy/gcm/whatif.py
imports: from typing import Any, Callable, Dict, Iterable, List, Optional, Union
  import networkx
  import numpy
  import pandas
  from dowhy.gcm._noise import compute_noise_from_data
  from dowhy.gcm.causal_mechanisms import ClassifierFCM
  from dowhy.gcm.causal_models import InvertibleStructuralCausalModel, ProbabilisticCausalModel, StructuralCausalModel, validate_causal_dag
  from dowhy.gcm.fitting_sampling import draw_samples
  from dowhy.graph import DirectedGraph, get_ordered_predecessors, is_root_node, node_connected_subgraph_view, validate_node_in_graph
label_desc: Use image node_id 1 for calling a global function with example usage: interventional_samples(causal_model, interventions, observed_data, num_samples_to_draw) and returns: _interventional_samples