switch from `training_args.bin` `training_args.json`
Author: not-lain
Pull request: yes

# What does this PR do?

switch from  `training_args.bin` to `training_args.json` and only capture the parameters that the user passed 
I'm using the same approach we are using in huggingface_hub's [PyTorchModelHubMixin](https://github.com/huggingface/huggingface_hub/blob/503d35355fa79ede904665c944e0a247e85c8af7/src/huggingface_hub/hub_mixin.py#L277) to store as little parameters as possible.
a minimalistic approach to test this is pr

```py
from transformers import TrainingArguments
args = TrainingArguments(output_dir="folder",eval_strategy="no") # or any other paramters
print(args.to_json_string())
# outputs
"""
{
  "output_dir": "folder",
  "eval_strategy": "no",
  "logging_dir": "folder\\runs\\Nov29_02-44-45_iphone-laptop"
}
"""
# logging_dir is a special parameter that is always captured and added to the training_args because we want to ensure consistency

# stores the parameters into a file
args.to_json_file("training_args.json")

# loads an instance using the class directly
args2  = TrainingArguments.from_json_file("training_args.json") 
```

using this approach, we ensure that we only store the parameters that the user-defined manually and not the ones that have default values or the ones inferred from the system (ie cpu, cuda, tpu ... ), leaving some room for flexibility.

in a sense the parameters are mutable, meaning the user can physically alter them.


Fixes #34612 


## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#create-a-pull-request),
      Pull Request section?
- [x] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [ ] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?


## Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@muellerzr @SunMarc 

Comments:
cc @muellerzr & @SunMarc for review.
failed test is unrelated

friendly tagging @muellerzr & @SunMarc
failed tests are unrelated

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_35010). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

[don't merge yet I need to fix something fundamental that was not captured by the tests]



cc @muellerzr for feedback
I implemented a rollback, now default is `traing_args.bin` and people can switch to `training_args.json` by setting the `TRAINER_SAFE_SERIALIZE` environmental variable.

originally there was never a mechanism inside of the trainer API to load any training_args and people used to load the training arguments manually, I added something useful which is `TrainingArguments.from_json_file(file_name )` 
but I think I will integrate this loading mechanism with the trainer api in another pr (optional new feature)


friendly tagging @muellerzr here for a review.

cc @muellerzr for review 

cc @SunMarc for review

I've switched to dynamic serialization which something that came up with to tackle #25903 .
this will serialize the parameters needed to make the training arguments **lighweight, mutable and reproducible.**

here's a thorough example on what to expect : 
```py
from transformers import TrainingArguments
args = TrainingArguments(output_dir="folder",eval_strategy="no") # or any other parameters
print(args.to_json_string())
# outputs (logging_dir needs to stay consistant in case we want tensorboard to continue the plots)
"""
{
  "output_dir": "folder",
  "eval_strategy": "no",
  "logging_dir": "folder\\runs\\Dec27_21-48-40_iphone-laptop"
}
"""
# has some default parameters in the method which have been captured and serialized
# this also captures manually set parameters in either args or kwargs format.
args = args.set_dataloader() 
print(args.to_json_string())
# outputs
"""
{
  "output_dir": "folder",
  "eval_strategy": "no",
  "logging_dir": "folder\\runs\\Dec27_21-48-40_iphone-laptop",
  "auto_find_batch_size": false,
  "ignore_data_skip": false
}
"""
# save and reload
args.to_json_file("training_args.json")
args2  = TrainingArguments.from_json_file("training_args.json")
print(args2.to_json_string())
# output
"""
{
  "output_dir": "folder",
  "eval_strategy": "no",
  "logging_dir": "folder\\runs\\Dec27_21-48-40_iphone-laptop",
  "auto_find_batch_size": false,
  "ignore_data_skip": false
}
"""
```

let me know if you have any reviews

friendly tagging @muellerzr for feedback.

cc @muellerzr if you can take a look

tagging @muellerzr if can you give a final review on this pr

the `test_missing_stateful_callback` is now failing, any recommendations on how to approach this?

cc @muellerzr , failing tests are unrelated

friendly tagging @muellerzr  for review

cc @muellerzr for review

friendly tagging @muellerzr here for review

cc @muellerzr to see if you can review this 

cc @ArthurZucker for review 🤗

this pr is related to https://github.com/huggingface/transformers/pull/35010/files#diff-bfceaff300c851b8e24fc50dc6638482abaec8f7d2a718e877c3828c166bcf79L223 where  it said  : 
>  TODO: `TrainingArguments` users rely on it being fully mutable. In the future see if we can narrow this to a few keys: https://github.com/huggingface/transformers/pull/25903

in short this pr : 
* switch from bin -> json (better security) 
* training args become fully mutable
* dynamic parameter serialization (storing only key parameters) (see  https://github.com/huggingface/transformers/pull/35010#issuecomment-2564059045  for more details ) 

do not hesitate if you have any questions or follow-ups 🤗

Can you fix the conflicts ? Then, we will finally be able to merge it ;) 

done (≧∇≦)ﾉ