code: def parse(docstring):
      """Returns DocstringInfo about the given docstring.
  
      This parser aims to parse Google, numpy, and rst formatted docstrings. These
      are the three most common docstring styles at the time of this writing.
  
      This parser aims to be permissive, working even when the docstring deviates
      from the strict recommendations of these styles.
  
      This parser does not aim to fully extract all structured information from a
      docstring, since there are simply too many ways to structure information in a
      docstring. Sometimes content will remain as unstructured text and simply gets
      included in the description.
  
      The Google docstring style guide is available at:
      https://github.com/google/styleguide/blob/gh-pages/pyguide.md
  
      The numpy docstring style guide is available at:
      https://numpydoc.readthedocs.io/en/latest/format.html
  
      Information about the rST docstring format is available at:
      https://www.python.org/dev/peps/pep-0287/
      The full set of directives such as param and type for rST docstrings are at:
      http://www.sphinx-doc.org/en/master/usage/restructuredtext/domains.html
  
      Note: This function does not claim to handle all docstrings well. A list of
      limitations is available at the top of the file. It does aim to run without
      crashing in O(n) time on all strings on length n. If you find a string that
      causes this to crash or run unacceptably slowly, please consider submitting
      a pull request.
  
      Args:
        docstring: The docstring to parse.
  
      Returns:
        A DocstringInfo containing information about the docstring.
      """
      if docstring is None:
          return DocstringInfo()
  
      lines = docstring.strip().split("\n")
      lines_len = len(lines)
      state = Namespace()  # TODO(dbieber): Switch to an explicit class.
  
      # Variables in state include:
      state.section.title = None
      state.section.indentation = None
      state.section.line1_indentation = None
      state.section.format = None
      state.summary.permitted = True
      state.summary.lines = []
      state.description.lines = []
      state.args = []
      state.kwargs = []
      state.current_arg = None
      state.returns.lines = []
      state.yields.lines = []
      state.raises.lines = []
  
      for index, line in enumerate(lines):
          has_next = index + 1 < lines_len
          previous_line = lines[index - 1] if index > 0 else None
          next_line = lines[index + 1] if has_next else None
          line_info = _create_line_info(line, next_line, previous_line)
          _consume_line(line_info, state)
  
      summary = (
          " ".join(state.summary.lines) if state.summary.lines else None
      )
      state.description.lines = _strip_blank_lines(
          state.description.lines
      )
      description = textwrap.dedent("\n".join(state.description.lines))
      if not description:
          description = None
      returns = _join_lines(state.returns.lines)
      yields = _join_lines(state.yields.lines)
      raises = _join_lines(state.raises.lines)
  
      args = [
          ArgInfo(
              name=arg.name,
              type=_cast_to_known_type(_join_lines(arg.type.lines)),
              description=_join_lines(arg.description.lines),
          )
          for arg in state.args
      ]
  
      args.extend(
          [
              KwargInfo(
                  name=arg.name,
                  type=_cast_to_known_type(_join_lines(arg.type.lines)),
                  description=_join_lines(arg.description.lines),
              )
              for arg in state.kwargs
          ]
      )
  
      return DocstringInfo(
          summary=summary,
          description=description,
          args=args or None,
          returns=returns,
          raises=raises,
          yields=yields,
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  import enum
  import re
  import textwrap
label_desc: Use image node_id 1 for calling a global function with example usage: parse(docstring) and returns: DocstringInfo, DocstringInfo