code: def add_metric(self, metric: float) -> None:
          
          new_best = ((self._best_so_far is None) or
                      (self._should_decrease and metric < self._best_so_far) or
                      (not self._should_decrease and metric > self._best_so_far))
  
          if new_best:
              self.best_epoch = self._epoch_number
              self._is_best_so_far = True
              self._best_so_far = metric
              self._epochs_with_no_improvement = 0
          else:
              self._is_best_so_far = False
              self._epochs_with_no_improvement += 1
          self._epoch_number += 1
docs: Record a new value of the metric and update the various things that depend on it.