class_docstr: WorkloadResponseInterceptor is a class that can send some precanned workload messages, as the
  TrialWorkloadManager might send to the TrialController, but then intercept the responses and
  offer them via .result().
  
  This is basically syntactic sugar to make writing unit tests feel more declarative even when
  unit tests need to be written as WorkloadIterators (i.e. generator coroutines).
  
  Example usage:
  
      def make_workloads():
          interceptor = WorkloadResponseInterceptor()
  
          # Yield some workload message to the TrialController.
          yield from interceptor.send(my_workload)
  
          # Check that the result is appropriate.
          check.is_reasonable(interceptor.result())
  
          ...
  
      # Create a Trial to read this stream of workloads.
      controller = MyTrialController(..., make_workloads())
  
      # Run the workloads to completion.
      controller.run()
class_docstr_tok: ["WorkloadResponseInterceptor","is","a","class","that","can","send","some","precanned","workload","messages",",","as","the","TrialWorkloadManager","might","send","to","the","TrialController",",","but","then","intercept","the","responses","and","offer","them","via",".result","(",")",".","This","is","basically","syntactic","sugar","to","make","writing","unit","tests","feel","more","declarative","even","when","unit","tests","need","to","be","written","as","WorkloadIterators","(","i.e",".","generator","coroutines",")",".","Example","usage",":","def","make_workloads","(",")",":","interceptor","=","WorkloadResponseInterceptor","(",")","#","Yield","some","workload","message","to","the","TrialController",".","yield","from","interceptor.send","(","my_workload",")","#","Check","that","the","result","is","appropriate",".","check.is_reasonable","(","interceptor.result","(",")",")","...","#","Create","a","Trial","to","read","this","stream","of","workloads",".","controller","=","MyTrialController","(","...",",","make_workloads","(",")",")","#","Run","the","workloads","to","completion",".","controller.run","(",")"]
docstr: Identical to result but disallow workload.InvalidHP responses.
docstr_tok: ["Identical","to","result","but","disallow","workload.InvalidHP","responses","."]
code: def metrics_result(self) -> Metrics:
      """Identical to result but disallow workload.InvalidHP responses."""
      check.is_not_none(
          self._response,
          "_respond() was not called by the TrialController.",
      )
      check.is_instance(
          self._response, dict, "unexpected InvalidHP response."
      )
      return cast(Metrics, self._response)
  
imports: import abc
  from enum import Enum, unique
  from typing import Any, Callable, Dict, Iterator, Optional, Tuple, Union, cast
  from determined.common import check
label_desc: Use image node_id 5 for calling the WorkloadResponseInterceptor obj's underlying member method code with example usage: obj.metrics_result() and returns: cast