code: def timed_operation(msg, log_start=False):
      """
      Surround a context with a timer.
  
      Args:
          msg(str): the log to print.
          log_start(bool): whether to print also at the beginning.
  
      Example:
          .. code-block:: python
  
              with timed_operation('Good Stuff'):
                  time.sleep(1)
  
          Will print:
  
          .. code-block:: python
  
              Good stuff finished, time:1sec.
      """
      assert len(msg)
      if log_start:
          logger.info("Start {} ...".format(msg))
      start = timer()
      yield
      msg = msg[0].upper() + msg[1:]
      logger.info(
          "{} finished, time:{:.4f} sec.".format(msg, timer() - start)
      )
  
imports: import atexit
  from collections import defaultdict
  from contextlib import contextmanager
  from time import perf_counter
  from .None import logger
  from .stats import StatCounter
label_desc: Use image node_id 1 for calling a global function with example usage: timed_operation(msg, log_start) without return types