def add_eval_result(self, checkpoint_path: str, result_dict: Dict[str, Any],
                      default_value: int = -1) -> None:
    """Add eval result to the CSV file."""
    if jax.process_index() == 0:
      step = int(os.path.basename(checkpoint_path).split('_')[-1])
      csv_header = ['checkpoint_path', 'step'] + sorted(result_dict)
      write_header = not tf.io.gfile.exists(self._score_file)
      if write_header:
        with tf.io.gfile.GFile(self._score_file, 'w') as f:
          writer = csv.DictWriter(
              f, fieldnames=csv_header, extrasaction='ignore'
          )
          writer.writeheader()
      row = dict(checkpoint_path=checkpoint_path, step=str(step))
      for k, v in result_dict.items():
        if isinstance(v, float):
          v = '{:.3f}'.format(v)
        row[k] = v
      with tf.io.gfile.GFile(self._score_file, 'a') as f:
        writer = csv.DictWriter(f, fieldnames=csv_header, extrasaction='ignore')
        writer.writerow(row)
Add eval result to the CSV file.
videogvt/train_lib/task_manager.py