Dynamic Class/Panel Creation

My goal is to programmatically display the node group settings but separate them into subpanels. For example the script might loop through the node group’s inputs. The node group has a couple inputs that are empty (not connected to anything in the node group) that are used mainly as a label on the node group. The script would create a new subpanel every time it finds a label and would continue displaying the inputs that follow until finding another empty input. Is this possible? I’ve found python’s type() function but I’m not sure how to do it exactly with blender’s classes and then how to add all the correct "def"s and how to pass stuff to it for the subpanel labels and whatnot. Any thoughts out there?