docs: def warn(message, category=None, stacklevel=1, emitstacklevel=1):
      """Issue a warning, or maybe ignore it or raise an exception.
  
      Duplicate of the standard library warn function except it takes the
      following argument:
  
      `emitstacklevel` : default to 1, number of stackframe to consider when
      matching the module that emits this warning.
      """
      # Check if message is already a Warning object
  
      ####################
      ### Get category ###
      ####################
      if isinstance(message, Warning):
          category = message.__class__
      # Check category argument
      if category is None:
          category = UserWarning
      if not (isinstance(category, type) and issubclass(category, Warning)):
          raise TypeError("category must be a Warning subclass, "
                          "not '{:s}'".format(type(category).__name__))
      # Get context information
      try:
          frame = _get_stack_frame(stacklevel)
      except ValueError:
          globals = sys.__dict__
          lineno = 1
      else:
          globals = frame.f_globals
          lineno = frame.f_lineno
  
      try:
          eframe = _get_stack_frame(emitstacklevel)
      except ValueError:
          eglobals = sys.__dict__
      else:
          eglobals = eframe.f_globals
      if '__name__' in eglobals:
          emodule = eglobals['__name__']
      else:
          emodule = "<string>"
  
      ####################
      ### Get Filename ###
      ####################
      if '__name__' in globals:
          module = globals['__name__']
      else:
          module = "<string>"
      ####################
      ### Get Filename ###
      ####################
      filename = globals.get('__file__')
      if filename:
          fnl = filename.lower()
          if fnl.endswith(".pyc"):
              filename = filename[:-1]
      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
      registry = globals.setdefault("__warningregistry__", {})
      warn_explicit(message, category, filename, lineno, module, registry,
                    globals, emit_module=emodule)