class_docstr: Callback for saving intermediate model checkpoints.
docstr: Checks whether the current results are better than the best so far.
  
  Results are considered better if each metric is equal or better than the best so
  far, and at least one is better.
  
  Args:
      curr_results: The training metrics for this epoch.
docstr_tok: ["Checks","whether","the","current","results","are","better","than","the","best","so","far",".","Results","are","considered","better","if","each","metric","is","equal","or","better","than","the","best","so","far",",","and","at","least","one","is","better",".","Args",":","curr_results",":","The","training","metrics","for","this","epoch","."]
code: def _does_model_improve(self, curr_results: Dict[Text, Any]) -> bool:
      """Checks whether the current results are better than the best so far.
  
      Results are considered better if each metric is equal or better than the best so
      far, and at least one is better.
  
      Args:
          curr_results: The training metrics for this epoch.
      """
      curr_metric_names = [
          k
          for k in curr_results.keys()
          if k.startswith("val")
          and (k.endswith("_acc") or k.endswith("_f1"))
      ]
      # the "val" prefix is prepended to metrics in fit if _should_eval returns true
      # for this particular epoch
      if len(curr_metric_names) == 0:
          # the metrics are not validation metrics
          return False
      # initialize best_metrics_so_far with the first results
      if not self.best_metrics_so_far:
          for metric_name in curr_metric_names:
              self.best_metrics_so_far[metric_name] = float(
                  curr_results[metric_name]
              )
          return True
  
      at_least_one_improved = False
      improved_metrics = {}
      for metric_name in self.best_metrics_so_far.keys():
          if (
              float(curr_results[metric_name])
              < self.best_metrics_so_far[metric_name]
          ):
              # at least one of the values is worse
              return False
          if (
              float(curr_results[metric_name])
              > self.best_metrics_so_far[metric_name]
          ):
              at_least_one_improved = True
              improved_metrics[metric_name] = float(
                  curr_results[metric_name]
              )
  
      # all current values >= previous best and at least one is better
      if at_least_one_improved:
          self.best_metrics_so_far.update(improved_metrics)
      return at_least_one_improved
  
file_path: rasa/rasa/utils/tensorflow/callback.py
imports: from pathlib import Path
  from typing import Dict, Text, Any, Optional
  import logging
  import tensorflow
  from tqdm import tqdm
  import rasa.shared.utils.io
label_desc: Use image node_id 3 for calling the RasaModelCheckpoint obj's underlying member method code with example usage: obj._does_model_improve(curr_results) and returns: at_least_one_improved, False, True, False