code: def _prune(dir_: str, epochs: int) -> None:
      
      for logdir in [path.join(dir_, f) for f in listdir(dir_) if path.isdir(path.join(dir_, f))]:
          if not is_train_dir(logdir):
              _safe_rmtree(logdir)
          else:
              trace_path = path.join(logdir, CXF_TRACE_FILE)
              try:
                  epochs_done = TrainingTrace.from_file(trace_path)[TrainingTraceKeys.EPOCHS_DONE]
              except (KeyError, TypeError):
                  epochs_done = 0
              if not epochs_done or epochs_done < epochs:
                  _safe_rmtree(logdir)
docs: Delete all training dirs with incomplete training artifacts or with less than specified epochs done.
  
      :param dir_: dir with training log dirs
      :param epochs: minimum number of finished epochs to keep the training logs
      :return: number of log dirs pruned