Add time-based evaluation strategy to Trainer
Author: ailunc
Pull request: yes

# What does this PR do?

**Add time-based evaluation strategy to Trainer**

This PR introduces a time-based evaluation, saving, and logging strategy to the Hugging Face `Trainer`. Previously, the Trainer only supported step-based intervals, which can be inconvenient when running on different hardware setups (e.g., slower local CPU vs fast GPU cluster). Step-based intervals don’t translate well across environments with different speeds, making time-based configuration more practical and flexible.

This change enables configurations like:
```python
training_args = TrainingArguments(
    output_dir="./test_output",
    eval_strategy=IntervalStrategy.TIME,      # Evaluate every N minutes
    eval_minutes=1,

    save_strategy=IntervalStrategy.TIME,      # Save every N minutes
    save_minutes=1,

    logging_strategy=IntervalStrategy.TIME,   # Log every N minutes
    logging_minutes=1,

    per_device_train_batch_size=8,
    num_train_epochs=200,
)
```

This is especially helpful for:
- Avoiding lost progress during long training jobs by saving periodically
- Keeping evaluation frequency consistent across devices and batch sizes
- Monitoring model progress during training in time-based intervals

Fixes #36310

**Dependencies**: None

---

## Before submitting

- [x] This PR improves Trainer functionality (not just docs or typos)
- [x] I have read the [contributor guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#create-a-pull-request)
- [x] This feature was discussed in [issue #36310](https://github.com/huggingface/transformers/issues/36310)
- [x] I have updated/added documentation where necessary
- [x] I have written new tests to cover this functionality

---

## Tests

New tests have been added in `tests/test_time_based_strategy.py` to verify the core functionalities of the time-based strategies:

1. `test_eval_time_based`:  
   - Validates that evaluation is triggered correctly using `eval_strategy=IntervalStrategy.TIME` and `eval_minutes=1`.

2. `test_save_time_based`:  
   - Verifies that model checkpoints are saved based on time intervals using `save_strategy=IntervalStrategy.TIME` and `save_minutes=1`.

3. `test_logging_time_based`:  
   - Checks that logs are written at time-based intervals using `logging_strategy=IntervalStrategy.TIME` and `logging_minutes=1`.

All tests use `distilbert-base-uncased` on the SST-2 dataset and run for a large number of epochs (`num_train_epochs=200`) to ensure that evaluation, saving, and logging occur multiple times. These tests confirm the correct integration and behavior of the time-based strategy during training.

---

## Contributors

- @zhuallen @Zephyr271828 @LuHC409 @Harry-Yang0518

---

## Who can review?

- @zach-huggingface  
- @SunMarc


Comments:
Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. The CI will be paused while the PR is in draft mode. When it is ready for review, please click the `Ready for review` button (at the bottom of the PR page). This will assign reviewers and trigger CI.

Once this is ready for review feel free to ping @SunMarc !