code: def get_noise_dependent_function(
      causal_model: StructuralCausalModel,
      target_node: Any,
      approx_prediction_model: Optional[PredictionModel] = None,
      num_training_samples: int = 20000,
  ) -> Tuple[Callable[[np.ndarray], np.ndarray], List[Any]]:
      """Returns a function that represents the given target_node and that is only dependent on upstream noise nodes.
      This is, Y = f(N_0, N_1, ..., N_n), where Y is the target node and N_i the noise node of an upstream node. Since
      the order of the noise variables can be ambiguous, this method also returns a list with the expected order of the
      noise variables indicated by the name of the corresponding node. For instance:
      Lets say we have a target variable X4 which has only 2 other upstream variables X1 and X3, then this methods returns
      a callable that represents X4 = f(N_1, N_3, N_4). This callable expects a numpy array as input. Since the order
      of the columns in this array is unclear, the method also returns a list with the names of the corresponding columns,
      e.g. ['X1', 'X3', 'X4']. Note that the noise of X4 will also be an input variable here.
  
      If an approx_prediction_model is given, the model is used instead to train a model from scratch to represent f.
      Typically, it would be much faster to evaluate this model than propagating through the graph. The model is trained
      based on generated noise and target samples from the given causal graph. In theory, the approximated version of f
      should be close to the "true" one based on the underlying SCMs, but there can still be (significant) differences,
      especially if the provided model is inappropriate for representing f.
  
      Note: All nodes in the graph that have no direct path to the target node are omitted. The noise node of the
            target variable itself will also be included here.
  
      :param causal_model: A structural causal model.
      :param target_node: The target node for which the function f should be returned.
      :param approx_prediction_model: Prediction model for approximating f. The model is trained based on drawn noise and
                                      target samples.
      :param num_training_samples: Number of drawn samples for training the predictor based on the provided
                                   approx_prediction_model.
                                   Note: This parameter is ignored if approx_prediction_model is None.
      :return: A tuple, where the first value is a callable (the function f) that expects a numpy array X as input and
      the second value is a list with nodes that represents the expected order of the columns in X.
      """
      validate_causal_dag(causal_model.graph)
  
      if approx_prediction_model is not None:
          return _get_approx_noise_dependent_function(
              StructuralCausalModel(
                  node_connected_subgraph_view(
                      causal_model.graph, target_node
                  )
              ),
              target_node,
              approx_prediction_model,
              num_training_samples,
          )
      else:
          return _get_exact_noise_dependent_function(
              StructuralCausalModel(
                  node_connected_subgraph_view(
                      causal_model.graph, target_node
                  )
              ),
              target_node,
          )
  
file_path: dowhy/dowhy/gcm/_noise.py
imports: from typing import Any, Callable, List, Optional, Tuple
  import networkx
  import numpy
  import pandas
  from dowhy.gcm.causal_models import InvertibleStructuralCausalModel, ProbabilisticCausalModel, StructuralCausalModel, validate_causal_dag
  from dowhy.gcm.ml.prediction_model import PredictionModel
  from dowhy.gcm.util.general import shape_into_2d
  from dowhy.graph import get_ordered_predecessors, is_root_node, node_connected_subgraph_view
label_desc: Use image node_id 3 for calling a global function with example usage: get_noise_dependent_function(causal_model, target_node, approx_prediction_model, num_training_samples) and returns: _get_approx_noise_dependent_function, _get_exact_noise_dependent_function