code: def run_experiment(
      self,
      experiment_id: int,
      session: client.Session,
      prior_operations: Optional[List[searcher.Operation]],
      sleep_time: float = 1.0,
  ) -> None:
      experiment_is_active = True
      try:
          while experiment_is_active:
              time.sleep(
                  sleep_time
              )  # we don't want to call long polling API more often than every second.
              events = self.get_events(session, experiment_id)
              if not events:
                  continue
              logger.info(
                  json.dumps(
                      [
                          SearchRunner._searcher_event_as_dict(e)
                          for e in events
                      ]
                  )
              )
              # the first event is an event we have already processed and told master about it
              # however, we may not have saved the state after that event if we crashed
              # after POSTing operations but before saving state
              last_event_id = self.state.last_event_id
              first_event = True
              for event in events:
                  if (
                      first_event
                      and last_event_id != 0
                      and last_event_id >= event.id >= 0
                      and prior_operations is not None
                  ):
                      logger.info(
                          f"Resubmitting operations for event.id={event.id}"
                      )
                      operations = prior_operations
                  else:
                      if event.experimentInactive:
                          logger.info(
                              f"experiment {self.state.experiment_id} is "
                              f"inactive; state={event.experimentInactive.experimentState}"
                          )
                          if (
                              event.experimentInactive.experimentState
                              == bindings.experimentv1State.COMPLETED
                          ):
                              self.state.experiment_completed = True
                          elif (
                              event.experimentInactive.experimentState
                              == bindings.experimentv1State.ERROR
                          ):
                              self.state.experiment_failed = True
  
                          if (
                              event.experimentInactive.experimentState
                              == bindings.experimentv1State.PAUSED
                          ):
                              self._show_experiment_paused_msg()
                          else:
                              experiment_is_active = False
                          break
  
                      operations = self._get_operations(event)
  
                      # save state
                      self.state.last_event_id = event.id
                      self.save_state(experiment_id, operations)
  
                  first_event = False
                  self.post_operations(
                      session, experiment_id, event, operations
                  )
  
      except KeyboardInterrupt:
          print("Runner interrupted")
  
imports: import json
  import logging
  import os
  import pickle
  import time
  import uuid
  from pathlib import Path
  from typing import Any, Dict, Iterable, List, Optional, Sequence, Tuple, Union
  from determined import searcher
  from determined.common.api import bindings, errors
  from determined.experimental import client
label_desc: Use image node_id 3 for calling the SearchRunner obj's underlying member method code with example usage: obj.run_experiment(experiment_id, session, prior_operations, sleep_time) without return types