code: def _to_mermaid_image(graph: networkx.MultiDiGraph):
      """
      Renders a pipeline using Mermaid (hosted version at 'https://mermaid.ink'). Requires Internet access.
      """
      graph_styled = _to_mermaid_text(graph=graph)
  
      graphbytes = graph_styled.encode("ascii")
      base64_bytes = base64.b64encode(graphbytes)
      base64_string = base64_bytes.decode("ascii")
      url = "https://mermaid.ink/img/" + base64_string
  
      logging.debug("Rendeding graph at %s", url)
      try:
          resp = requests.get(url, timeout=10)
          if resp.status_code >= 400:
              logger.warning(
                  "Failed to draw the pipeline: https://mermaid.ink/img/ returned status %s",
                  resp.status_code,
              )
              logger.info("Exact URL requested: %s", url)
              logger.warning("No pipeline diagram will be saved.")
              resp.raise_for_status()
  
      except Exception as exc:  # pylint: disable=broad-except
          logger.warning(
              "Failed to draw the pipeline: could not connect to https://mermaid.ink/img/ (%s)",
              exc,
          )
          logger.info("Exact URL requested: %s", url)
          logger.warning("No pipeline diagram will be saved.")
          raise PipelineDrawingError(
              "There was an issue with https://mermaid.ink/, see the stacktrace for details."
          ) from exc
  
      return resp.content
  
imports: import logging
  import base64
  import requests
  import networkx
  from haystack.core.errors import PipelineDrawingError
  from haystack.core.type_utils import _type_name
label_desc: Use image node_id 1 for calling a global function with example usage: _to_mermaid_image(graph) and returns: resp