code: def _draw(
      graph: networkx.MultiDiGraph,
      path: Path,
      engine: RenderingEngines = "mermaid-image",
      style_map: Optional[Dict[str, str]] = None,
  ) -> None:
      """
      Renders the pipeline graph and saves it to file.
      """
      converted_graph = _convert(
          graph=graph, engine=engine, style_map=style_map
      )
  
      if engine == "graphviz":
          converted_graph.draw(path)
  
      elif engine == "mermaid-image":
          with open(path, "wb") as imagefile:
              imagefile.write(converted_graph)
  
      elif engine == "mermaid-text":
          with open((path), "w", encoding="utf-8") as textfile:
              textfile.write(converted_graph)
  
      else:
          raise ValueError(
              f"Unknown rendering engine '{engine}'. Choose one from: {get_args(RenderingEngines)}."
          )
  
      logger.debug("Pipeline diagram saved at %s", path)
  
file_path: haystack/haystack/core/pipeline/draw/draw.py
imports: from typing import Literal, Optional, Dict, get_args, Any
  import logging
  from pathlib import Path
  import networkx
  from haystack.core.pipeline.descriptions import find_pipeline_inputs, find_pipeline_outputs
  from haystack.core.pipeline.draw.graphviz import _to_agraph
  from haystack.core.pipeline.draw.mermaid import _to_mermaid_image, _to_mermaid_text
  from haystack.core.type_utils import _type_name
label_desc: Use image node_id 1 for calling a global function with example usage: _draw(graph, path, engine, style_map) without return types