code: def trim(docstring, marker=None):
      if isinstance(docstring, bytes):
          docstring = str(docstring, "utf-8")
  
      if not docstring:
          return ""
      # Convert tabs to spaces (following the normal Python rules)
      # and split into a list of lines:
      lines = docstring.expandtabs().splitlines()
      # Determine minimum indentation (first line doesn't count):
      indent = sys.maxsize
      for line in lines[1:]:
          stripped = line.lstrip()
          if stripped:
              indent = min(indent, len(line) - len(stripped))
      # Remove indentation (first line is special):
      trimmed = [lines[0].strip()]
      if indent < sys.maxsize:
          for line in lines[1:]:
              # replace existing REST marker with doc level marker
              stripped = line.lstrip().strip().rstrip()
              if (
                  marker is not None
                  and stripped
                  and all([s == stripped[0] for s in stripped])
                  and stripped[0] not in [":"]
              ):
                  line = line.replace(stripped[0], marker)
              trimmed.append(line[indent:].rstrip())
      # Strip off trailing and leading blank lines:
      while trimmed and not trimmed[-1]:
          trimmed.pop()
      while trimmed and not trimmed[0]:
          trimmed.pop(0)
      # Return a single string:
      return "\n".join(trimmed)
  
file_path: nipype/nipype/utils/misc.py
imports: import os
  import sys
  import re
  from collections.abc import Iterator
  from warnings import warn
  from looseversion import LooseVersion
  import numpy
  import textwrap
label_desc: Use image node_id 2 for calling a global function with example usage: trim(docstring, marker) and returns: str, str