code: def deprecated_method(
      method: t.Any, cls: t.Any, method_name: str, msg: str
  ) -> None:
      """Show deprecation warning about a magic method definition.
  
      Uses warn_explicit to bind warning to method definition instead of triggering code,
      which isn't relevant.
      """
      warn_msg = f"{cls.__name__}.{method_name} is deprecated in traitlets 4.1: {msg}"
  
      for parent in inspect.getmro(cls):
          if method_name in parent.__dict__:
              cls = parent
              break
      # limit deprecation messages to once per package
      package_name = cls.__module__.split(".", 1)[0]
      key = (package_name, msg)
      if not should_warn(key):
          return
      try:
          fname = inspect.getsourcefile(method) or "<unknown>"
          lineno = inspect.getsourcelines(method)[1] or 0
      except (OSError, TypeError) as e:
          # Failed to inspect for some reason
          warn(
              warn_msg + ("\n(inspection failed) %s" % e),
              DeprecationWarning,
              stacklevel=2,
          )
      else:
          warnings.warn_explicit(
              warn_msg, DeprecationWarning, fname, lineno
          )
  
file_path: catboost/contrib/python/traitlets/py3/traitlets/utils/warnings.py
imports: from __future__ import annotations
  import inspect
  import os
  import typing
  import warnings
label_desc: Use image node_id 2 for calling a global function with example usage: deprecated_method(method, cls, method_name, msg) without return types