code: def _convert(
      graph: networkx.MultiDiGraph,
      engine: RenderingEngines = "mermaid-image",
      style_map: Optional[Dict[str, str]] = None,
  ) -> Any:
      """
      Renders the pipeline graph with the correct render and returns it.
      """
      graph = _prepare_for_drawing(
          graph=graph, style_map=style_map or {}
      )
  
      if engine == "graphviz":
          return _to_agraph(graph=graph)
  
      if engine == "mermaid-image":
          return _to_mermaid_image(graph=graph)
  
      if engine == "mermaid-text":
          return _to_mermaid_text(graph=graph)
  
      raise ValueError(
          f"Unknown rendering engine '{engine}'. Choose one from: {get_args(RenderingEngines)}."
      )
  
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 2 for calling a global function with example usage: _convert(graph, engine, style_map) and returns: _to_agraph, _to_mermaid_image, _to_mermaid_text