class_docstr: The implementation of a custom hyperparameter tuning algorithm.
  
  To implement your specific hyperparameter tuning approach, subclass ``SearchMethod``
  overriding the event handler methods.
  
  Each event handler, except :meth:`progress() <determined.searcher.SearchMethod.progress>`
  returns a list of operations (``List[Operation]``) that will be submitted to master for
  processing.
  
  Currently, we support the following :class:`~Operation`:
  
  - :class:`~Create` - starts a new trial with a unique trial id and a set of hyperparameter
    values.
  - :class:`~ValidateAfter` - sets number of steps (i.e., batches or epochs) after which a
    validation is run for a trial with a given id.
  - :class:`~Progress` - updates the progress of the multi-trial experiment to the master.
  - :class:`~Close` - closes a trial with a given id.
  - :class:`~Shutdown` - closes the experiment.
  
  .. note::
  
      Do not modify ``searcher_state`` passed into event handlers.
class_docstr_tok: ["The","implementation","of","a","custom","hyperparameter","tuning","algorithm",".","To","implement","your","specific","hyperparameter","tuning","approach",",","subclass","``","SearchMethod","``","overriding","the","event","handler","methods",".","Each","event","handler",",","except",":","meth",":","`","progress","(",")","<","determined.searcher.SearchMethod.progress",">","`","returns","a","list","of","operations","(","``","List","[","Operation","]","``",")","that","will","be","submitted","to","master","for","processing",".","Currently",",","we","support","the","following",":","class",":","`","~Operation","`",":","-",":","class",":","`","~Create","`","-","starts","a","new","trial","with","a","unique","trial","id","and","a","set","of","hyperparameter","values",".","-",":","class",":","`","~ValidateAfter","`","-","sets","number","of","steps","(","i.e.",",","batches","or","epochs",")","after","which","a","validation","is","run","for","a","trial","with","a","given","id",".","-",":","class",":","`","~Progress","`","-","updates","the","progress","of","the","multi-trial","experiment","to","the","master",".","-",":","class",":","`","~Close","`","-","closes","a","trial","with","a","given","id",".","-",":","class",":","`","~Shutdown","`","-","closes","the","experiment",".","..","note",":",":","Do","not","modify","``","searcher_state","``","passed","into","event","handlers","."]
docstr: Informs the searcher that a trial has exited earlier than expected.
  
  Example:
  
  .. code:: python
  
      def on_trial_exited_early(
          self,
          searcher_state: SearcherState,
          request_id: uuid.UUID,
          exited_reason: ExitedReason,
      ) -> List[Operation]:
          if exited_reason == searcher.ExitedReason.USER_CANCELED:
              return [searcher.Shutdown(cancel=True)]
          if exited_reason == searcher.ExitedReason.INVALID_HP:
              return [searcher.Shutdown(failure=True)]
          if searcher_state.failures >= self.max_failures:
              return [searcher.Shutdown(failure=True)]
          return []
  
  .. note::
  
      The trial has already been internally closed when this callback is run.
      You do not need to explicitly issue a :class:`~Close` operation
  
  Args:
      searcher_state (SearcherState): Read-only current searcher state
      request_id (uuid.UUID): Request UUID of the Trial that exited early
      exited_reason (ExitedReason): The reason that the trial exited early
  
  Returns:
      List[Operation]: List of :class:`~Operation` to run in response to the given
      trial exiting early
docstr_tok: ["Informs","the","searcher","that","a","trial","has","exited","earlier","than","expected",".","Example",":","..","code",":",":","python","def","on_trial_exited_early","(","self",",","searcher_state",":","SearcherState",",","request_id",":","uuid.UUID",",","exited_reason",":","ExitedReason",",",")","-",">","List","[","Operation","]",":","if","exited_reason","==","searcher.ExitedReason.USER_CANCELED",":","return","[","searcher.Shutdown","(","cancel=True",")","]","if","exited_reason","==","searcher.ExitedReason.INVALID_HP",":","return","[","searcher.Shutdown","(","failure=True",")","]","if","searcher_state.failures",">","=","self.max_failures",":","return","[","searcher.Shutdown","(","failure=True",")","]","return","[","]","..","note",":",":","The","trial","has","already","been","internally","closed","when","this","callback","is","run",".","You","do","not","need","to","explicitly","issue","a",":","class",":","`","~Close","`","operation","Args",":","searcher_state","(","SearcherState",")",":","Read-only","current","searcher","state","request_id","(","uuid.UUID",")",":","Request","UUID","of","the","Trial","that","exited","early","exited_reason","(","ExitedReason",")",":","The","reason","that","the","trial","exited","early","Returns",":","List","[","Operation","]",":","List","of",":","class",":","`","~Operation","`","to","run","in","response","to","the","given","trial","exiting","early"]
code: def on_trial_exited_early(
      self,
      searcher_state: SearcherState,
      request_id: uuid.UUID,
      exited_reason: ExitedReason,
  ) -> List[Operation]:
      """
      Informs the searcher that a trial has exited earlier than expected.
  
      Example:
  
      .. code:: python
  
          def on_trial_exited_early(
              self,
              searcher_state: SearcherState,
              request_id: uuid.UUID,
              exited_reason: ExitedReason,
          ) -> List[Operation]:
              if exited_reason == searcher.ExitedReason.USER_CANCELED:
                  return [searcher.Shutdown(cancel=True)]
              if exited_reason == searcher.ExitedReason.INVALID_HP:
                  return [searcher.Shutdown(failure=True)]
              if searcher_state.failures >= self.max_failures:
                  return [searcher.Shutdown(failure=True)]
              return []
  
      .. note::
  
          The trial has already been internally closed when this callback is run.
          You do not need to explicitly issue a :class:`~Close` operation
  
      Args:
          searcher_state (SearcherState): Read-only current searcher state
          request_id (uuid.UUID): Request UUID of the Trial that exited early
          exited_reason (ExitedReason): The reason that the trial exited early
  
      Returns:
          List[Operation]: List of :class:`~Operation` to run in response to the given
          trial exiting early
      """
      pass
  
imports: import abc
  import dataclasses
  import json
  import pathlib
  import uuid
  from abc import abstractmethod
  from enum import Enum
  from typing import Any, Dict, List, Optional, Set, Tuple
  from determined import experimental
  from determined.common.api import bindings
label_desc: Use image node_id 6 for calling the SearchMethod obj's underlying member method code with example usage: obj.on_trial_exited_early(searcher_state, request_id, exited_reason) without return types