code: def serialized(func):
      """Decorator to provide mutual exclusion for method using _lock attribute."""
  
      @functools.wraps(func)
      def serialized_method(self, *args, **kwargs):
          lock = getattr(self, "_lock")
          with lock:
              return func(self, *args, **kwargs)
  
      return serialized_method
  
file_path: magenta/magenta/common/concurrency.py
imports: import functools
  import threading
  import time
label_desc: Use image node_id 1 for calling a global function with example usage: serialized(func) and returns: serialized_method, func