code: def predict_using_all_nodes(
      bn: BayesianNetwork,
      data: pd.DataFrame,
      target_var: str,
      markov_blanket: bool = False,
      lv_name: str = "LV",
  ) -> pd.DataFrame:
      """
      Compute marginals using all nodes
  
      Args:
          bn: Bayesian network
          data: Input dataframe
          target_var: Target variable name
          markov_blanket: Whether to compute marginals based only on Markov blanket of the target variable
          lv_name: Latent variable name
  
      Returns:
          Marginal dataframe
      """
      # Extract columns of interest
      if markov_blanket:
          blanket = bn.structure.get_markov_blanket(
              [target_var, lv_name]
          )
          cols_to_keep = blanket.nodes
      else:
          cols_to_keep = bn.nodes
  
      # Further drop target variable and latent variable (if applicable)
      cols_to_keep = [
          col
          for col in cols_to_keep
          if col not in {target_var, lv_name}
      ]
  
      # Perform inference
      ie = InferenceEngine(bn)
      observations = data[cols_to_keep].to_dict(orient="records")
      marginals = [prob[target_var] for prob in ie.query(observations)]
      return pd.DataFrame(marginals)
  
imports: import json
  import multiprocessing
  import os
  import warnings
  from collections import defaultdict
  from time import time
  from typing import List, Tuple
  import dataframe_image
  import networkx
  import numpy
  import pandas
  from IPython.core.display import display
  from IPython.display import Image
  from sklearn import metrics
  from sklearn.model_selection import KFold
  from causalnex.evaluation import roc_auc
  from causalnex.inference import InferenceEngine
  from causalnex.network import BayesianNetwork
  from causalnex.plots import plot_structure
  from causalnex.structure import StructureModel
label_desc: Use image node_id 5 for calling a global function with example usage: predict_using_all_nodes(bn, data, target_var, markov_blanket, lv_name) and returns: pd