code: def synchronized(lock=None):
      """Decorator that synchronizes a method or a function with a mutex lock.
  
      Example usage:
  
          @synchronized()
          def operation(self, a, b):
              ...
      """
      if lock is None:
          lock = threading.Lock()
  
      def wrapper(function):
          def new_function(*args, **kwargs):
              lock.acquire()
              try:
                  return function(*args, **kwargs)
              finally:
                  lock.release()
  
          return new_function
  
      return wrapper
  
file_path: wandb/wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/decorators.py
imports: import functools
  import warnings
  import threading
  import sys
label_desc: Use image node_id 1 for calling a global function with example usage: synchronized(lock) and returns: wrapper, new_function, function