code: def bn(train_data_idx, train_data_discrete) -> BayesianNetwork:
      """Perform structure learning and CPD estimation"""
      return BayesianNetwork(
          from_pandas(train_data_idx, w_threshold=0.3)
      ).fit_node_states_and_cpds(train_data_discrete)
  
imports: import itertools
  from typing import Dict
  import numpy
  import pandas
  import pytest
  from pgmpy.models import BayesianNetwork
  from sklearn.datasets import load_iris
  from causalnex.discretiser import Discretiser
  from causalnex.network import BayesianNetwork
  from causalnex.structure import StructureModel
  from causalnex.structure.notears import from_pandas
label_desc: Use image node_id 16 for calling a global function with example usage: bn(train_data_idx, train_data_discrete) and returns: BayesianNetwork