code: def test_wait_waits_until_terminal_state(
      make_expref: Callable[[int], experiment.Experiment],
      terminal_state: experiment.ExperimentState,
  ) -> None:
      expref = make_expref(1)
  
      exp_resp_running = api_responses.sample_get_experiment(
          id=expref.id, state=bindings.experimentv1State.RUNNING
      )
      exp_resp_terminal = api_responses.sample_get_experiment(
          id=expref.id, state=terminal_state
      )
  
      responses.get(
          f"{_MASTER}/api/v1/experiments/{expref.id}",
          json=exp_resp_running.to_json(),
      )
      responses.get(
          f"{_MASTER}/api/v1/experiments/{expref.id}",
          json=exp_resp_running.to_json(),
      )
      responses.get(
          f"{_MASTER}/api/v1/experiments/{expref.id}",
          json=exp_resp_terminal.to_json(),
      )
  
      expref.wait(interval=0.01)
  
      # Register an extra response so the mock can keep serving the experiment
      #   (necessary for the `expref.reload() call below)
      responses.get(
          f"{_MASTER}/api/v1/experiments/{expref.id}",
          json=exp_resp_terminal.to_json(),
      )
      expref.reload()
      assert expref.state == terminal_state
  
imports: import base64
  import math
  import os
  from typing import Callable
  from unittest import mock
  import pytest
  import requests
  import responses
  from determined.common import api
  from determined.common.api import bindings
  from determined.common.experimental import checkpoint, determined, experiment
  from tests.fixtures import api_responses
label_desc: Use image node_id 4 for calling a global function with example usage: test_wait_waits_until_terminal_state(make_expref, terminal_state) without return types