code: def aup_args(func):
      """Decorator to wrap optimization target function `func`.
  
      Arguments:
          func {function} -- A function computes optimization target with specified hyperparameters
      """
  
      @functools.wraps(func)
      def wrapper(filename, **kwargs):
          """wrapper function
  
          Arguments:
              filename {str} -- configuration file
              kwargs {dict} -- additional arguments will overwrite existing configuration value
          Raises:
              ValueError: if a parameter is not assigned in config
          """
          # get current frame stack
          frm = inspect.stack()[1]
          # get module from stack
          mod = inspect.getmodule(frm[0])
          # get functions that contain "init" in name and call them
          functions_list = inspect.getmembers(
              sys.modules[mod.__name__], inspect.isfunction
          )
          functions_list = sorted(
              list(filter(lambda x: "init" in x[0], functions_list))
          )
  
          config = BasicConfig().load(filename)
          if kwargs:
              logger.critical(
                  "Overwritting config values from script, be cautious!"
              )
              config.update(kwargs)
  
          for f in functions_list:
              f[1](**config)
  
          parameters = inspect.signature(func).parameters
          for p in parameters.items():
              if p[0] not in config:
                  if p[1].default is inspect.Parameter.empty:
                      raise ValueError(
                          "`%s` is required in `%s()` but is not assigned in config file %s"
                          % (p[0], func.__name__, filename)
                      )
                  logger.info("Using default value for %s", p[0])
          run_config = dict()
          for p in config:
              if p in parameters:
                  run_config[p] = config[p]
              else:
                  logger.warning("%s is not used in optimization" % p)
  
          val = func(**run_config)
          print_result(val)
  
          save_model = config.get("save_model", False)
          if save_model is True:
              # this means this is the "best job" found
              # the user wants to save the model
              try:
                  dir = config.get("folder_name", None)
                  previous_dir = os.getcwd()
  
                  if os.path.exists(dir) is True:
                      logger.warning("Deleting {}".format(dir))
                      shutil.rmtree(dir)
  
                  os.makedirs(dir)
                  os.chdir(dir)
  
                  assert (
                      user_callback_fn is not None
                  ), "Please use 'aup_save_model' to register the save model callback fn"
                  user_callback_fn(*user_args, **user_kwargs)
              except Exception as e:
                  raise e
              finally:
                  os.chdir(previous_dir)
  
      return wrapper
  
imports: from __future__ import print_function
  import logging
  import json
  import pickle
  import sys
  import inspect
  import functools
  import os
  import shutil
label_desc: Use image node_id 2 for calling a global function with example usage: aup_args(func) and returns: wrapper