code: def _build_ground_truth(
      bn: BayesianNetwork,
      data: pd.DataFrame,
      node: str,
  ) -> pd.DataFrame:
      """
      Utility function to build ground truth from data
  
      Args:
          bn: Bayesian network
          data: Input dataframe
          node: Node name
  
      Returns:
          Ground truth dataframe
      """
      ground_truth = pd.get_dummies(data[node])
  
      # it's possible that not all states are present in the test set, so we need to add them to ground truth
      for dummy in bn.node_states[node]:
          if dummy not in ground_truth.columns:
              ground_truth[dummy] = [
                  0 for _ in range(len(ground_truth))
              ]
  
      # update ground truth column names to be correct, since we may have added missing columns
      return ground_truth[sorted(ground_truth.columns)]
  
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 6 for calling a global function with example usage: _build_ground_truth(bn, data, node) and returns: ground_truth