code: def make_extension(
      trigger=None,
      default_name=None,
      priority=None,
      finalizer=None,
      initializer=None,
      on_error=None,
      **kwargs,
  ):
      """Decorator to make given functions into trainer extensions.
  
      This decorator just adds some attributes to a given function. The value of
      the attributes are given by the arguments of this decorator.
  
      See :class:`Extension` for details of trainer extensions. Most of the
      default values of arguments also follow those for this class.
  
      Args:
          trigger: Default trigger of the extension.
          default_name: Default name of the extension. The name of a given
              function is used by default.
          priority (int): Default priority of the extension.
          finalizer: Finalizer function of this extension. It is
              called at the end of the training loop.
          initializer: Initializer function of this extension. It is called at
              the beginning of the training loop.
          on_error: Error handler callback function of this extension. It is
              called after an error is raised during the trainer loop.
  
      """
      if kwargs:
          msg = (
              "invoke_before_training has been removed since Chainer v2.0.0. "
              "Use initializer= instead."
          )
          argument.check_unexpected_kwargs(
              kwargs, invoke_before_training=msg
          )
          argument.assert_kwargs_empty(kwargs)
  
      if trigger is None:
          trigger = Extension.trigger
      if priority is None:
          priority = Extension.priority
  
      def decorator(ext):
          ext.trigger = trigger
          ext.default_name = default_name or ext.__name__
          ext.priority = priority
          ext.finalize = finalizer
          ext.on_error = on_error
          ext.initialize = initializer
          return ext
  
      return decorator
  
file_path: chainer/chainer/training/extension.py
imports: from chainer.utils import argument
label_desc: Use image node_id 1 for calling a global function with example usage: make_extension(trigger, default_name, priority, finalizer, initializer, on_error) and returns: decorator, ext