code: def convert_rst_links(text):
      """Convert the rst links in text to markdown."""
      # Links of the form :doc:`page`
      text = _re_simple_doc.sub(
          r"[\1](" + DOC_BASE_URL + r"\1.html)", text
      )
      # Links of the form :doc:`text <page>`
      text = _re_doc_with_description.sub(
          r"[\1](" + DOC_BASE_URL + r"\2.html)", text
      )
      # Refs of the form :ref:`page`
      text = _re_simple_ref.sub(r"[\1](#\1)", text)
      # Refs of the form :ref:`text <page>`
      text = _re_ref_with_description.sub(r"[\1](#\2)", text)
  
      # Other links
      def _rep_links(match):
          text, url = match.groups()
          if not url.startswith("http"):
              url = DOC_BASE_URL + url
          return f"[{text}]({url})"
  
      text = _re_links.sub(_rep_links, text)
      return text
  
imports: import nbformat
  import os
  import re
  import shutil
label_desc: Use image node_id 4 for calling a global function with example usage: convert_rst_links(text) and returns: text, str, text, str, url, str