code: def toplevel_group_data(overlay):
      pres = overlay.nodes[-1]
      tops = [pres]
      while pres.inputs:
          pres = pres.gcd
          tops.append(pres)
      tops = tops[::-1]
  
      groups = {}
  
      for top in tops:
          if top.op in ["Concat", "ConcatV2"]:
              groups[top.name] = {
                  "immediate": _namify(overlay.sorted(top.inputs)),
                  "all": _namify(
                      overlay.sorted(
                          top.extended_inputs
                          - top.gcd.extended_inputs
                          - set([top.gcd])
                          | set([top])
                      )
                  ),
                  "direction": "backward",
              }
          if len(top.consumers) > 1 and all(
              out.op == "Split" for out in top.consumers
          ):
              groups[top.name] = {
                  "immediate": _namify(overlay.sorted(top.consumers)),
                  "all": _namify(
                      overlay.sorted(
                          top.extended_consumers
                          - top.lcm.extended_consumers
                          - set([top.lcm])
                          | set([top])
                      )
                  ),
                  "direction": "forward",
              }
  
      return groups
  
file_path: lucid/lucid/misc/graph_analysis/parse_overlay.py
imports: from lucid.misc.graph_analysis.overlay_graph import OverlayGraph, OverlayNode, OverlayStructure
label_desc: Use image node_id 7 for calling a global function with example usage: toplevel_group_data(overlay) and returns: groups