code: def warn(msg, stacklevel=1, function=None):
      if function is not None:
          import inspect
  
          filename = inspect.getfile(function)
          lineno = py.code.getrawcode(function).co_firstlineno
      else:
          try:
              caller = sys._getframe(stacklevel)
          except ValueError:
              globals = sys.__dict__
              lineno = 1
          else:
              globals = caller.f_globals
              lineno = caller.f_lineno
          if "__name__" in globals:
              module = globals["__name__"]
          else:
              module = "<string>"
          filename = globals.get("__file__")
      if filename:
          fnl = filename.lower()
          if fnl.endswith(".pyc") or fnl.endswith(".pyo"):
              filename = filename[:-1]
          elif fnl.endswith("$py.class"):
              filename = filename.replace("$py.class", ".py")
      else:
          if module == "__main__":
              try:
                  filename = sys.argv[0]
              except AttributeError:
                  # embedded interpreters don't have sys.argv, see bug #839151
                  filename = "__main__"
          if not filename:
              filename = module
      path = py.path.local(filename)
      warning = DeprecationWarning(msg, path, lineno)
      import warnings
  
      warnings.warn_explicit(
          warning,
          category=Warning,
          filename=str(warning.path),
          lineno=warning.lineno,
          registry=warnings.__dict__.setdefault(
              "__warningsregistry__", {}
          ),
      )
  
imports: import py, sys
label_desc: Use image node_id 2 for calling a global function with example usage: warn(msg, stacklevel, function) without return types