code: def watch_statuses(self, observer, batch_ids):
          
          with self._lock:
              statuses = self.get_statuses(batch_ids)
              if self._has_no_pendings(statuses):
                  observer.notify_batches_finished(statuses)
              else:
                  self._observers[observer] = statuses
docs: Allows a component to register to be notified when a set of
          batches is no longer PENDING. Expects to be able to call the
          "notify_batches_finished" method on the registered component, sending
          the statuses of the batches.
  
          Args:
              observer (object): Must implement "notify_batches_finished" method
              batch_ids (list of str): The ids of the batches to watch