code: def yield_and_await_response(
      wkld: workload.Workload,
  ) -> Generator[WorkloadStreamElem, None, workload.Response]:
      """
      rb: I didn't know that generators could return meaningful values when I designed the layers
      abstraction of the harness.  If I had, I would have used it all over, most likely in place of
      the response_func.
  
      yield_and_await_response is a convenience function that yields a value and a response func, then
      returns whatever got passed in the response func.
  
      It's not worth refactoring all of the layers of the harness to use this pattern because the
      whole harness is getting refactored with push architecture, and the layers will be a thing of
      the past.
      """
      out: Optional[workload.Response] = None
  
      def respond(r: workload.Response) -> None:
          nonlocal out
          out = r
  
      yield wkld, respond
  
      assert out is not None
  
      return out
  
imports: import logging
  import sys
  from typing import Any, Generator, Optional, Tuple
  import determined
  from determined import core, util, workload
  from determined.common import check
label_desc: Use image node_id 1 for calling a global function with example usage: yield_and_await_response(wkld) and returns: out