code: def _wait(self, key, state, rendezvous_id):
      while True:
          try:
              self._barrier.wait()
              return rendezvous_id
          except threading.BrokenBarrierError:
              if self._barrier.broken:
                  # Timeout or other non-recoverable error, so exit
                  raise
  
              # Barrier has been reset
              with self._lock:
                  # Check to make sure the reset was not caused by a change of state for this key
                  rendezvous_id = self._rendezvous_id
                  saved_state = self._states.get(key, state)
                  if saved_state != state:
                      # This worker changed its state, so do not attempt to wait again to avoid double-counting
                      raise RuntimeError(
                          "State {} overridden by {}".format(
                              state, saved_state
                          )
                      )
  
file_path: horovod/horovod/runner/elastic/registration.py
imports: import logging
  import threading
  from collections import defaultdict
  from horovod.runner.elastic import constants
label_desc: Use image node_id 12 for calling the WorkerStateRegistry obj's underlying member method code with example usage: obj._wait(key, state, rendezvous_id) and returns: rendezvous_id