code: def Deprecated_args(
      min_version_to_warn: str,
      min_version_to_error: str,
      custom_warning_msg: Optional[str] = None,
      version_to_remove: Optional[str] = None,
      _ag_version: Optional[str] = None,
      **kwargs_mapping,
  ):
      """
      Decorator to add deprecation warnings or raise an error to deprecated arguments.
      If not raising error, will replace the deprecated argument with the new one.
  
      Parameters
      ----------
      min_version_to_warn: str,
          Minimum ag version to show deprecation warning.
          If the installed ag version is >= min_version_to_warn, a deprecation warning will be generated.
      min_version_to_error: str,
          Minimum ag version to raise deprecation error.
          If the installed ag version is >= min_version_to_error, a deprecation error will be raised.
      custom_warning_msg: Optional[str], default = None,
          Custom warning message to display.
          If not specified, will prompt in the following format:
              ```python
              msg = f"`{old}` has been deprecated. "
              msg += f"And will be removed in version {version_to_remove} " if version_to_remove is not None else ""
              msg += (
                  f"Please use `{new}` instead"
                  if new is not None
                  else ""
              )
              ```
      version_to_remove: Optional[str], default = None,
          AG version when the object will be removed. Will be added to the warning message if specified
      kwargs_mapping
          Mapping between deprecated_arg and new_arg, i.e. kwargs_mapping={"deprecated_arg": "new_args"}
          If the argument is being deprecated and won't be replaced by other new arg, set it to None, i.e. kwargs_mapping={"deprecated_arg": None}
  
      Examples
      --------
      >>> # Deprecate a renamed argument
      >>> @Deprecated_args(min_version_to_warn="1.0", min_version_to_error="1.1", old_arg="new_arg")
      >>> def myfunc(new_arg):  # Old argument can be removed from function signature
      >>>     ...
      >>>
      >>> @Deprecated_args(min_version_to_warn="1.0", min_version_to_error="1.1", deprecated_arg_with_no_replacement=None)
      >>> def myfunc(deprecated_arg_with_no_replacement):  # This argument need to still exists for it to work
      >>>     ...
      """
  
      def _decorator(obj):
          error = False
          ag_version = __version__
          if _ag_version is not None:
              ag_version = _ag_version
          if version.parse(ag_version) < version.parse(
              min_version_to_warn
          ):
              return obj
          if version.parse(ag_version) >= version.parse(
              min_version_to_error
          ):
              error = True
  
          @functools.wraps(obj)
          def patched_obj_with_warning_msg(*args, **kwargs):
              _rename_kwargs(
                  func_name=obj.__name__,
                  kwargs=kwargs,
                  kwargs_mapping=kwargs_mapping,
                  custom_warning_msg=custom_warning_msg,
                  version_to_remove=version_to_remove,
                  error=error,
              )
              return obj(*args, **kwargs)
  
          return patched_obj_with_warning_msg
  
      return _decorator
  
file_path: autogluon/common/src/autogluon/common/utils/deprecated_utils.py
imports: import functools
  import inspect
  import warnings
  from typing import Any, Callable, Dict, Optional
  from packaging import version
  from ..version import __version__
label_desc: Use image node_id 4 for calling a global function with example usage: Deprecated_args(min_version_to_warn, min_version_to_error, custom_warning_msg, version_to_remove, _ag_version) and returns: _decorator, patched_obj_with_warning_msg, obj, obj