def save_checkpoint_if_best(eval_result,
                            checkpoint_path,
                            to_dir,
                            to_checkpoint_name = BEST_CHECKPOINT_FILENAME,
                            higher_is_better = True):
  """Copies a checkpoint if it is the best so far.

  Args:
    eval_result: The new eval result.
    checkpoint_path: Specific checkpoint path to compare and copy.
    to_dir: The target directory to copy to.
    to_checkpoint_name: The target checkpoint name to copy to.
    higher_is_better: Whether higher eval numbers are better.

  Returns:
    Whether the new eval result is better than the previous one.
  """
  is_better = update_eval_info(to_dir, eval_result, higher_is_better)

  if is_better:
    copy_checkpoint(checkpoint_path, to_dir, to_checkpoint_name)

  return is_better
Copies a checkpoint if it is the best so far.

  Args:
    eval_result: The new eval result.
    checkpoint_path: Specific checkpoint path to compare and copy.
    to_dir: The target directory to copy to.
    to_checkpoint_name: The target checkpoint name to copy to.
    higher_is_better: Whether higher eval numbers are better.

  Returns:
    Whether the new eval result is better than the previous one.
  
language/multivec/models/checkpoint_utils.py