code: def on_trial_result(self, trial_runner, trial, result):
          
  
          if trial in self._stopped_trials:
              assert not self._hard_stop
              return TrialScheduler.CONTINUE  # fall back to FIFO
  
          time = result[self._time_attr]
          self._results[trial].append(result)
          median_result = self._get_median_result(time)
          best_result = self._best_result(trial)
          if self._verbose:
              logger.info("Trial {} best res={} vs median res={} at t={}".format(
                  trial, best_result, median_result, time))
          if best_result < median_result and time > self._grace_period:
              if self._verbose:
                  logger.info("MedianStoppingRule: "
                              "early stopping {}".format(trial))
              self._stopped_trials.add(trial)
              if self._hard_stop:
                  return TrialScheduler.STOP
              else:
                  return TrialScheduler.PAUSE
          else:
              return TrialScheduler.CONTINUE
docs: Callback for early stopping.
  
          This stopping rule stops a running trial if the trial's best objective
          value by step `t` is strictly worse than the median of the running
          averages of all completed trials' objectives reported up to step `t`.