code: def wait_for_ntsc_state(
      session: api.Session,
      typ: NTSC_Kind,
      ntsc_id: str,
      predicate: Callable[[bindings.taskv1State], bool],
      timeout: int = 10,  # seconds
  ) -> bindings.taskv1State:
      """wait for ntsc to reach a state that satisfies the predicate"""
  
      def get_state() -> Tuple[bool, bindings.taskv1State]:
          last_state = get_ntsc_details(session, typ, ntsc_id).state
          return predicate(last_state), last_state
  
      return util.wait_for(get_state, timeout)
  
file_path: determined/harness/determined/common/api/_util.py
imports: import enum
  from typing import Callable, Iterator, Optional, Tuple, TypeVar, Union
  import urllib3
  from determined.common import api, util
  from determined.common.api import bindings
label_desc: Use image node_id 4 for calling a global function with example usage: wait_for_ntsc_state(session, typ, ntsc_id, predicate, timeout) and returns: util, predicate,  last_state