code: def captured_function(wrapped, instance, args, kwargs):
      options = fallback_dict(
          wrapped.config,
          _config=wrapped.config,
          _log=wrapped.logger,
          _run=wrapped.run,
      )
      if (
          wrapped.uses_randomness
      ):  # only generate _seed and _rnd if needed
          options["_seed"] = get_seed(wrapped.rnd)
          options["_rnd"] = create_rnd(options["_seed"])
  
      bound = instance is not None
      args, kwargs = wrapped.signature.construct_arguments(
          args, kwargs, options, bound
      )
      if wrapped.logger is not None:
          wrapped.logger.debug("Started")
          start_time = time.time()
      # =================== run actual function =================================
      with ConfigError.track(wrapped.config, wrapped.prefix):
          result = wrapped(*args, **kwargs)
      # =========================================================================
      if wrapped.logger is not None:
          stop_time = time.time()
          elapsed_time = timedelta(
              seconds=round(stop_time - start_time)
          )
          wrapped.logger.debug("Finished after %s.", elapsed_time)
  
      return result
  
file_path: sacred/sacred/config/captured_function.py
imports: import time
  from datetime import timedelta
  import wrapt
  from sacred.config.custom_containers import fallback_dict
  from sacred.config.signature import Signature
  from sacred.randomness import create_rnd, get_seed
  from sacred.utils import ConfigError
label_desc: Use image node_id 2 for calling a global function with example usage: captured_function(wrapped, instance, args, kwargs) and returns: result