code: def _add_deprecated_method(
      cls: type, old_method_name: str, new_method_name: str
  ):
      method = getattr(cls, new_method_name)
  
      @wraps(method)
      def _deprecated_method(self, *args, **kwargs):
          warnings.warn(
              f"LazyTensor#{old_method_name} has been renamed to LinearOperator#{method.__name__}",
              DeprecationWarning,
          )
          return method(self, *args, **kwargs)
  
      setattr(cls, old_method_name, _deprecated_method)
  
imports: import warnings
  from functools import wraps
  from typing import Union
  import torch
  from linear_operator import LinearOperator, to_dense
label_desc: Use image node_id 1 for calling a global function with example usage: _add_deprecated_method(cls, old_method_name, new_method_name) and returns: method