code: def _get_operations(
      self, event: bindings.v1SearcherEvent
  ) -> List[searcher.Operation]:
      if event.initialOperations:
          logger.info("initial operations")
          operations = self.search_method.initial_operations(self.state)
      elif event.trialCreated:
          logger.info(f"trialCreated({event.trialCreated.requestId})")
          request_id = uuid.UUID(event.trialCreated.requestId)
          self.state.trials_created.add(request_id)
          self.state.trial_progress[request_id] = 0.0
          operations = self.search_method.on_trial_created(
              self.state, request_id
          )
      elif event.trialClosed:
          logger.info(f"trialClosed({event.trialClosed.requestId})")
          request_id = uuid.UUID(event.trialClosed.requestId)
          self.state.trials_closed.add(request_id)
          operations = self.search_method.on_trial_closed(
              self.state, request_id
          )
  
          # add progress operation
          progress = self.search_method.progress(self.state)
          operations.append(searcher.Progress(progress))
      elif event.trialExitedEarly:
          # duplicate exit accounting already performed by master
          searcher_exit_reason = searcher.ExitedReason._from_bindings(
              event.trialExitedEarly.exitedReason
          )
          logger.info(
              f"trialExitedEarly({event.trialExitedEarly.requestId}, {searcher_exit_reason})"
          )
          if event.trialExitedEarly.exitedReason is None:
              raise RuntimeError(
                  "trialExitedEarly event is invalid without exitedReason"
              )
          request_id = uuid.UUID(event.trialExitedEarly.requestId)
          if (
              event.trialExitedEarly.exitedReason
              == bindings.v1TrialExitedEarlyExitedReason.INVALID_HP
          ):
              self.state.trial_progress.pop(request_id, None)
          elif (
              event.trialExitedEarly.exitedReason
              == bindings.v1TrialExitedEarlyExitedReason.UNSPECIFIED
          ):
              self.state.failures.add(request_id)
          operations = self.search_method.on_trial_exited_early(
              self.state,
              request_id,
              exited_reason=searcher_exit_reason,
          )
          # add progress operation
          progress = self.search_method.progress(self.state)
          operations.append(searcher.Progress(progress))
      elif event.validationCompleted:
          # duplicate completion accounting already performed by master
          logger.info(
              f"validationCompleted({event.validationCompleted.requestId},"
              f" {event.validationCompleted.metric})"
          )
          request_id = uuid.UUID(event.validationCompleted.requestId)
          if event.validationCompleted.metric is None:
              raise RuntimeError(
                  "validationCompleted event is invalid without a metric"
              )
  
          operations = self.search_method.on_validation_completed(
              self.state,
              request_id,
              event.validationCompleted.metric,
              int(event.validationCompleted.validateAfterLength),
          )
          # add progress operation
          progress = self.search_method.progress(self.state)
          operations.append(searcher.Progress(progress))
      elif event.experimentInactive:
          logger.info(
              f"experiment {self.state.experiment_id} is "
              f"inactive; state={event.experimentInactive.experimentState}"
          )
  
          raise _ExperimentInactiveException(
              event.experimentInactive.experimentState
          )
      elif event.trialProgress:
          logger.debug(
              f"trialProgress({event.trialProgress.requestId}, "
              f"{event.trialProgress.partialUnits})"
          )
          request_id = uuid.UUID(event.trialProgress.requestId)
          self.state.trial_progress[request_id] = float(
              event.trialProgress.partialUnits
          )
          progress = self.search_method.progress(self.state)
          operations = [searcher.Progress(progress)]
      else:
          raise RuntimeError(f"Unsupported event {event}")
      return operations
  
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 2 for calling the SearchRunner obj's underlying member method code with example usage: obj._get_operations(event) and returns: operations