code: def mangle_docstrings(
      app, what, name, obj, options, lines, reference_offset=[0]
  ):
      cfg = {
          "use_plots": app.config.numpydoc_use_plots,
          "show_class_members": app.config.numpydoc_show_class_members,
          "show_inherited_class_members": app.config.numpydoc_show_inherited_class_members,
          "class_members_toctree": app.config.numpydoc_class_members_toctree,
      }
  
      u_NL = "\n"
      if what == "module":
          # Strip top title
          pattern = "^\\s*[#*=]{4,}\\n[a-z0-9 -]+\\n[#*=]{4,}\\s*"
          title_re = re.compile(pattern, re.I | re.S)
          lines[:] = title_re.sub("", u_NL.join(lines)).split(u_NL)
      else:
          doc = get_doc_object(obj, what, u_NL.join(lines), config=cfg)
          doc = str(doc)
          lines[:] = doc.split(u_NL)
  
      if (
          app.config.numpydoc_edit_link
          and hasattr(obj, "__name__")
          and obj.__name__
      ):
          if hasattr(obj, "__module__"):
              v = dict(
                  full_name="%s.%s" % (obj.__module__, obj.__name__)
              )
          else:
              v = dict(full_name=obj.__name__)
          lines += ["", ".. htmlonly::", ""]
          lines += [
              "    %s" % x
              for x in (app.config.numpydoc_edit_link % v).split("\n")
          ]
  
      # replace reference numbers so that there are no duplicates
      references = []
      for line in lines:
          line = line.strip()
          m = re.match("^.. \\[([a-z0-9_.-])\\]", line, re.I)
          if m:
              references.append(m.group(1))
  
      # start renaming from the longest string, to avoid overwriting parts
      references.sort(key=lambda x: -len(x))
      if references:
          for i, line in enumerate(lines):
              for r in references:
                  if re.match("^\\d+$", r):
                      new_r = "R%d" % (reference_offset[0] + int(r))
                  else:
                      new_r = "%s%d" % (r, reference_offset[0])
                  lines[i] = lines[i].replace(
                      "[%s]_" % r, "[%s]_" % new_r
                  )
                  lines[i] = lines[i].replace(
                      ".. [%s]" % r, ".. [%s]" % new_r
                  )
  
      reference_offset[0] += len(references)
  
imports: import re
  import pydoc
  import sphinx
  import inspect
  import collections
  from docscrape_sphinx import SphinxDocString
  from docutils.statemachine import ViewList
  from sphinx.domains.c import CDomain
  from sphinx.domains.python import PythonDomain
label_desc: Use image node_id 1 for calling a global function with example usage: mangle_docstrings(app, what, name, obj, options, lines, reference_offset) without return types