class_docstr: A threadsafe, singleton wrapper for time.sleep that improves accuracy.
  
  The time.sleep function is inaccurate and sometimes returns early or late. To
  improve accuracy, this class sleeps for a shorter time than requested and
  enters a spin lock for the remainder of the requested time.
  
  The offset is automatically calibrated based on when the thread is actually
  woken from sleep by increasing/decreasing the offset halfway between its
  current value and `_MIN_OFFSET`.
  
  Accurate to approximately 5ms after some initial burn-in.
  
  Args:
    initial_offset: The initial amount to shorten the time.sleep call in float
        seconds.
  Raises:
    ValueError: When `initial_offset` is less than `_MIN_OFFSET`.
code: def __init__(self, initial_offset=0.001):
      if initial_offset < Sleeper._MIN_OFFSET:
          raise ValueError(
              "`initial_offset` must be at least %f. Got %f."
              % (Sleeper._MIN_OFFSET, initial_offset)
          )
      self._lock = threading.RLock()
      self.offset = initial_offset
  
file_path: magenta/magenta/common/concurrency.py
imports: import functools
  import threading
  import time
label_desc: Use image node_id 1 to create a new Sleeper object from inherited base classes: object with example: obj = Sleeper(initial_offset)