code: def deprecated(deprecated_by, msg="", use_deprecated=True):
      """Decorator that creates a dummy class or function that returns the class/fun it is deprecated by,
              along with a warning
  
          Adapted from https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/utils/deprecation.py
          but we want to return the new class or function here instead.
  
      Parameters
      ----------
      deprecated_by : function or class
          the new function or class that deprecates the one that is being wrapped
      msg : str, default is ''
          optional message to display in the deprecation warning
      use_deprecated : bool, default is True
          if True, the deprecated wrapped function/class will be used with a warning
          if False, the new class/function will be used along with the deprecation warning for the old name
      """
  
      class DeprecatedBy(object):
          def __init__(self):
              self.deprecated_by = deprecated_by
              self.use_deprecated = use_deprecated
              self.msg = msg
  
          def __call__(self, obj):
              if isinstance(obj, type):
                  return self._wrap_class(obj)
  
              else:
                  return self._wrap_fun(obj)
  
          def _wrap_fun(self, fun):
              def wrapped(*args, **kwargs):
                  msg = f"{fun.__name__} is deprecated, use {self.deprecated_by.__name__} instead."
                  if self.msg:
                      msg += "\n" + {self.msg}
  
                  warnings.warn(msg, DeprecationWarning)
                  if self.use_deprecated:
                      return fun(*args, **kwargs)
                  else:
                      return self.deprecated_by(*args, **kwargs)
  
              return wrapped
  
          def _wrap_class(self, cls):
              if self.use_deprecated:
                  Base = cls
              else:
                  Base = self.deprecated_by
  
              class Wrapped(Base):
                  def __init__(wrapped_self, *args, **kwargs):
                      msg = f"{cls.__name__} is deprecated, use {self.deprecated_by.__name__} instead."
                      if self.msg:
                          msg += "\n" + {self.msg}
  
                      warnings.warn(msg, DeprecationWarning)
                      super().__init__(*args, **kwargs)
  
              Wrapped.__name__ = cls.__name__
              return Wrapped
  
      return DeprecatedBy()
  
imports: import warnings
label_desc: Use image node_id 1 for calling a global function with example usage: deprecated(deprecated_by, msg, use_deprecated) and returns: DeprecatedBy, wrapped, Wrapped, self, self, fun, self