code: def alter_interface_docs_for_api(docs):
      """Apply modifications to interface docstrings for Python API use."""
      # central place to alter the impression of docstrings,
      # like removing cmdline specific sections
      if not docs:
          return docs
      docs = dedent_docstring(docs)
      # clean cmdline sections
      docs = re.sub(
          r"\|\| CMDLINE \>\>.*?\<\< CMDLINE \|\|",
          "",
          docs,
          flags=re.MULTILINE | re.DOTALL,
      )
      # clean cmdline in-line bits
      docs = re.sub(
          r"\[CMD:\s.*?\sCMD\]",
          "",
          docs,
          flags=re.MULTILINE | re.DOTALL,
      )
      docs = re.sub(
          r"\[PY:\s(.*?)\sPY\]",
          lambda match: match.group(1),
          docs,
          flags=re.MULTILINE | re.DOTALL,
      )
      # select only the python alternative from argument specifications
      docs = re.sub(
          r"``([a-zA-Z0-9_,.]+)\|\|([a-zA-Z0-9-,.]+)``",
          lambda match: f"``{match.group(1)}``",
          docs,
      )
      docs = re.sub(
          r"\|\| PYTHON \>\>(.*?)\<\< PYTHON \|\|",
          lambda match: match.group(1),
          docs,
          flags=re.MULTILINE | re.DOTALL,
      )
      if "DATALAD_SPHINX_RUN" not in os.environ:
          # remove :role:`...` RST markup for cmdline docs
          docs = re.sub(
              r":\S+:`[^`]*`[\\]*",
              lambda match: ":".join(
                  match.group(0).split(":")[2:]
              ).strip("`\\"),
              docs,
              flags=re.MULTILINE | re.DOTALL,
          )
          # make the handbook doc references more accessible
          # the URL is a redirect configured at readthedocs
          docs = re.sub(
              r"(handbook:[0-9]-[0-9]*)",
              "\\1 (http://handbook.datalad.org/symbols)",
              docs,
          )
      docs = re.sub(
          r"^([ ]*)\|\| REFLOW \>\>\n(.*?)\<\< REFLOW \|\|",
          lambda match: textwrap.fill(
              match.group(2), subsequent_indent=match.group(1)
          ),
          docs,
          flags=re.MULTILINE | re.DOTALL,
      )
      return docs
  
imports: import inspect
  import logging
  import os
  import re
  import textwrap
  import warnings
  from abc import ABC, abstractmethod
  from functools import wraps
  from importlib import import_module
  from typing import Callable, Dict, Generator, TypeVar, TYPE_CHECKING
  import datalad
  from datalad import cfg
  from datalad.core.local.resulthooks import get_jsonhooks_from_config, match_jsonhook2result, run_jsonhook
  from datalad.distribution.dataset import Dataset, resolve_path
  from datalad.interface.common_opts import eval_params
  from datalad.interface.results import known_result_xfms
  from datalad.interface.utils import get_result_filter, keep_result, render_action_summary, xfm_result, _process_results
  from datalad.support.exceptions import CapturedException, IncompleteResultsError
  from datalad.utils import get_wrapped_class
label_desc: Use image node_id 7 for calling a global function with example usage: alter_interface_docs_for_api(docs) and returns: docs, docs