code: def deprecate_with_version(
      message,
      since="",
      until="",
      version_comparator=cmp_pkg_version,
      warn_class=DeprecationWarning,
      error_class=ExpiredDeprecationError,
  ):
      """Return decorator function function for deprecation warning / error.
  
      The decorated function / method will:
  
      * Raise the given `warning_class` warning when the function / method gets
        called, up to (and including) version `until` (if specified);
      * Raise the given `error_class` error when the function / method gets
        called, when the package version is greater than version `until` (if
        specified).
  
      Parameters
      ----------
      message : str
          Message explaining deprecation, giving possible alternatives.
      since : str, optional
          Released version at which object was first deprecated.
      until : str, optional
          Last released version at which this function will still raise a
          deprecation warning.  Versions higher than this will raise an
          error.
      version_comparator : callable
          Callable accepting string as argument, and return 1 if string
          represents a higher version than encoded in the `version_comparator`, 0
          if the version is equal, and -1 if the version is lower.  For example,
          the `version_comparator` may compare the input version string to the
          current package version string.
      warn_class : class, optional
          Class of warning to generate for deprecation.
      error_class : class, optional
          Class of error to generate when `version_comparator` returns 1 for a
          given argument of ``until``.
  
      Returns
      -------
      deprecator : func
          Function returning a decorator.
  
      """
      messages = [message]
      if (since, until) != ("", ""):
          messages.append("")
      if since:
          messages.append("* deprecated from version: " + since)
      if until:
          messages.append(
              "* {0} {1} as of version: {2}".format(
                  "Raises" if is_bad_version(until) else "Will raise",
                  error_class,
                  until,
              )
          )
      message = "\n".join(messages)
  
      def deprecator(func):
          @functools.wraps(func)
          def deprecated_func(*args, **kwargs):
              if until and is_bad_version(until, version_comparator):
                  raise error_class(message)
              warnings.warn(message, warn_class, stacklevel=2)
              return func(*args, **kwargs)
  
          deprecated_func.__doc__ = _add_dep_doc(
              deprecated_func.__doc__, message
          )
          return deprecated_func
  
      return deprecator
  
file_path: dipy/dipy/utils/deprecator.py
imports: import functools
  import warnings
  import re
  from inspect import signature
  from dipy import __version__
  from packaging.version import parse
label_desc: Use image node_id 5 for calling a global function with example usage: deprecate_with_version(message, since, until, version_comparator, warn_class, error_class) and returns: deprecator, deprecated_func, func