code: def repr_errors(
      res, estimator=None, method: Optional[str] = None
  ) -> str:
      """Pretty print original docstring and the obtained errors
  
      Parameters
      ----------
      res : dict
          result of numpydoc.validate.validate
      estimator : {estimator, None}
          estimator object or None
      method : str
          if estimator is not None, either the method name or None.
  
      Returns
      -------
      str
         String representation of the error.
      """
      if method is None:
          if hasattr(estimator, "__init__"):
              method = "__init__"
          elif estimator is None:
              raise ValueError(
                  "At least one of estimator, method should be provided"
              )
          else:
              raise NotImplementedError
  
      if estimator is not None:
          obj = getattr(estimator, method)
          try:
              obj_signature = signature(obj)
          except TypeError:
              # In particular we can't parse the signature of properties
              obj_signature = (
                  "\nParsing of the method signature failed, "
                  "possibly because this is a property."
              )
  
          obj_name = estimator.__name__ + "." + method
      else:
          obj_signature = ""
          obj_name = method
  
      msg = "\n\n" + "\n\n".join(
          [
              str(res["file"]),
              obj_name + str(obj_signature),
              res["docstring"],
              "# Errors",
              "\n".join(
                  " - {}: {}".format(code, message)
                  for code, message in res["errors"]
              ),
          ]
      )
      return msg
  
file_path: imbalanced-learn/maint_tools/test_docstring.py
imports: import importlib
  import inspect
  import pkgutil
  import re
  from inspect import signature
  from typing import Optional
  import pytest
  import imblearn
  from imblearn.utils.testing import all_estimators
label_desc: Use image node_id 5 for calling a global function with example usage: repr_errors(res, estimator, method) and returns: msg