code: def convert_B_stubs_to_ndarray(B_stubs, model_labels):
      """
      This function converts a list of multi-index pandas dataframes `B_stubs` into an object array
      of different B matrices, one per hidden state factor
      """
  
      (
          _,
          _,
          num_states,
          num_factors,
          num_controls,
          num_control_fac,
      ) = get_model_dimensions_from_labels(model_labels)
  
      B = obj_array(num_factors)
  
      for f, factor_name in enumerate(B_stubs.keys()):
          B[f] = (
              B_stubs[factor_name]
              .to_numpy()
              .reshape(num_states[f], num_states[f], num_controls[f])
          )
          assert (
              B[f].sum(axis=0) == 1.0
          ).all(), (
              "B matrix not normalized! Check your initialization....\n"
          )
  
      return B
  
imports: import numpy
  import pandas
  import seaborn
  import matplotlib.pyplot
  import warnings
  import itertools
label_desc: Use image node_id 34 for calling a global function with example usage: convert_B_stubs_to_ndarray(B_stubs, model_labels) and returns: B