code: def test_deprecated():
      # Test on function without docs, @deprecated without reasons
      @deprecated("0.4.2", "0.6.0")
      def func_no_docs():
          return 24
  
      assert (
          func_no_docs.__doc__
          == "**Deprecated function**.\n\n    .. deprecated:: 0.4.2"
      )
  
      # Test on function with docs, @deprecated without reasons
      @deprecated("0.4.2", "0.6.0")
      def func_no_reasons():
          """Docs are cool"""
          return 24
  
      assert (
          func_no_reasons.__doc__
          == "**Deprecated function**.\n\n    Docs are cool.. deprecated:: 0.4.2"
      )
  
      # Test on function with docs, @deprecated with reasons
      @deprecated("0.4.2", "0.6.0", reasons=("r1", "r2"))
      def func_no_warnings():
          """Docs are very cool"""
          return 24
  
      assert (
          func_no_warnings.__doc__
          == "**Deprecated function**.\n\n    Docs are very cool.. deprecated:: 0.4.2\n\n\t\n\t- r1\n\t- r2"
      )
  
      # Tests that the function emits DeprecationWarning
      @deprecated("0.4.2", "0.6.0", reasons=("r1", "r2"))
      def func_check_warning():
          """Docs are very ..."""
          return 24
  
      with pytest.deprecated_call():
          assert func_check_warning() == 24
      with pytest.warns(
          DeprecationWarning,
          match="This function has been deprecated since version 0.4.2 and will be removed in version 0.6.0."
          + "\n Please refer to the documentation for more details.",
      ):
          # Trigger a warning.
          func_check_warning()
  
      # Test that the function raises Exception
      @deprecated(
          "0.4.2",
          "0.6.0",
          reasons=("reason1", "reason2"),
          raise_exception=True,
      )
      def func_with_everything():
          return 1
  
      with pytest.raises(Exception) as exec_info:
          func_with_everything()
  
      assert (
          str(exec_info.value)
          == "This function has been deprecated since version 0.4.2 and will be removed in version 0.6.0."
          + "\n Please refer to the documentation for more details."
      )
  
file_path: ignite/tests/ignite/test_utils.py
imports: import logging
  import sys
  from collections import namedtuple
  import pytest
  import torch
  from packaging.version import Version
  from ignite.engine import Engine, Events
  from ignite.utils import convert_tensor, deprecated, hash_checkpoint, setup_logger, to_onehot
label_desc: Use image node_id 7 for calling a global function with example usage: test_deprecated() and returns: int, int, int, int, int