code: def serialize_pipeline(
      pipeline, versioned=True, funcs=None, dsets=None
  ):
      if dsets is None:
          dsets = {}
      if funcs is None:
          funcs = {}
  
      modules = []
      for module in pipeline.modules:
          if isinstance(module, Pipeline):
              modules.append(
                  serialize_pipeline(module, versioned, funcs, dsets)
              )
          else:
              modules.append(
                  serialize_module(module, versioned, funcs, dsets)
              )
      return {
          "type": "pipeline",
          "name": pipeline.__class__.__name__,
          "modules": modules,
      }
  
file_path: popmon/tools/pipeline_viz.py
imports: import json
  from itertools import cycle
  from pathlib import Path
  import pygraphviz
  from popmon.base import Pipeline
label_desc: Use image node_id 2 for calling a global function with example usage: serialize_pipeline(pipeline, versioned, funcs, dsets) and returns: dict