Adding a function for flattening the RBM structure.