code: def get_auc_data(
      df: pd.DataFrame,
      bn: BayesianNetwork,
      n_splits: int = 5,
      seed: int = 2021,
  ) -> pd.Series:
      """
      Utility function to compute AUC based only on data observations
  
      Args:
          df: Input dataframe
          bn: Bayesian network
          n_splits: Number of cross-validation folds
          seed: Random seed number
  
      Returns:
          Average AUC
      """
      bn.fit_node_states(df)
      cv = KFold(n_splits=n_splits, shuffle=True, random_state=seed)
      nodes_auc = defaultdict(list)
  
      for fold, (train_idx, test_idx) in enumerate(cv.split(df)):
          t0 = time()
          train_df = df.loc[train_idx, :]
          test_df = df.loc[test_idx, :]
          bn.fit_cpds(
              train_df, method="BayesianEstimator", bayes_prior="K2"
          )
  
          for var in bn.nodes:
              _, auc = roc_auc(bn, test_df, var)
              nodes_auc[var].append(auc)
  
          print(f"Processing fold {fold} takes {time() - t0} seconds")
  
      nodes_auc = pd.DataFrame(nodes_auc)
      col = nodes_auc.mean(axis=0).idxmin()
      val = nodes_auc.mean(axis=0).min()
      print(
          f"Variable with lowest AUC is {col} with the value of {val}"
      )
      return nodes_auc.mean().sort_values()
  
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 8 for calling a global function with example usage: get_auc_data(df, bn, n_splits, seed) and returns: nodes_auc