Error Using Ray Tune because of the repo id
Author: matiasfreitas
Pull request: no

### System Info

- `transformers` version: 4.30.0
- Platform: Linux-6.6.6-76060606-generic-x86_64-with-glibc2.35
- Python version: 3.11.5
- Huggingface_hub version: 0.15.1
- Safetensors version: 0.3.2
- PyTorch version (GPU?): 2.1.0+cu121 (True)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: <fill in>
- Using distributed or parallel set-up in script?: <fill in>

```
2024-01-19 11:54:21,786	ERROR tune_controller.py:911 -- Trial task failed for trial _objective_750f9_00002
Traceback (most recent call last):
  File "/home/matiasfg/anaconda3/envs/Dataset_Objects/lib/python3.10/site-packages/ray/air/execution/_internal/event_manager.py", line 110, in resolve_future
    result = ray.get(future)
  File "/home/matiasfg/anaconda3/envs/Dataset_Objects/lib/python3.10/site-packages/ray/_private/auto_init_hook.py", line 24, in auto_init_wrapper
    return fn(*args, **kwargs)
  File "/home/matiasfg/anaconda3/envs/Dataset_Objects/lib/python3.10/site-packages/ray/_private/client_mode_hook.py", line 103, in wrapper
    return func(*args, **kwargs)
  File "/home/matiasfg/anaconda3/envs/Dataset_Objects/lib/python3.10/site-packages/ray/_private/worker.py", line 2524, in get
    raise value.as_instanceof_cause()
ray.exceptions.RayTaskError(HFValidationError): ray::ImplicitFunc.train() (pid=198543, ip=192.168.1.83, actor_id=d99794869b3e484929cd90d501000000, repr=_objective)
  File "/home/matiasfg/anaconda3/envs/Dataset_Objects/lib/python3.10/site-packages/ray/tune/trainable/trainable.py", line 375, in train
    raise skipped from exception_cause(skipped)
  File "/home/matiasfg/anaconda3/envs/Dataset_Objects/lib/python3.10/site-packages/ray/tune/trainable/function_trainable.py", line 349, in entrypoint
    return self._trainable_func(
  File "/home/matiasfg/anaconda3/envs/Dataset_Objects/lib/python3.10/site-packages/ray/tune/trainable/function_trainable.py", line 666, in _trainable_func
    output = fn()
  File "/home/matiasfg/.local/lib/python3.10/site-packages/transformers/integrations/integration_utils.py", line 350, in dynamic_modules_import_trainable
    return trainable(*args, **kwargs)
  File "/home/matiasfg/anaconda3/envs/Dataset_Objects/lib/python3.10/site-packages/ray/tune/trainable/util.py", line 325, in inner
    return trainable(config, **fn_kwargs)
  File "/home/matiasfg/.local/lib/python3.10/site-packages/transformers/integrations/integration_utils.py", line 251, in _objective
    local_trainer.train(resume_from_checkpoint=checkpoint, trial=trial)
  File "/home/matiasfg/.local/lib/python3.10/site-packages/transformers/trainer.py", line 1514, in train
    self.model = self.call_model_init(trial)
  File "/home/matiasfg/.local/lib/python3.10/site-packages/transformers/trainer.py", line 1260, in call_model_init
    model = self.model_init(trial)
  File "/tmp/ipykernel_197623/1278964700.py", line 8, in getModel
  File "/home/matiasfg/.local/lib/python3.10/site-packages/transformers/modeling_utils.py", line 2600, in from_pretrained
    resolved_config_file = cached_file(
  File "/home/matiasfg/.local/lib/python3.10/site-packages/transformers/utils/hub.py", line 431, in cached_file
    resolved_file = hf_hub_download(
  File "/home/matiasfg/.local/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py", line 110, in _inner_fn
    validate_repo_id(arg_value)
  File "/home/matiasfg/.local/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py", line 164, in validate_repo_id
    raise HFValidationError(
huggingface_hub.utils._validators.HFValidationError: Repo id must use alphanumeric chars or '-', '_', '.', '--' and '..' are forbidden, '-' and '.' cannot start or end the name, max length is 96: '{'learning_rate': 8.288916866885153e-06, 'num_train_epochs': 5, 'seed': 24.443485457985144, 'per_device_train_batch_size': 16}'.
```

### Who can help?

@muellerzr @pacman100 @richardliaw @amogkam

### Information

- [ ] The official example scripts
- [X] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [X] My own task or dataset (give details below)

### Reproduction

Running that code with any trainer that code sounds enough, but not sure. 

trainer.hyperparameter_search(direction="maximize", backend="ray", n_trials=10)
trainer.train()

### Expected behavior

A name on the standards of the validator should be used as repo id. 

Comments:
Hi @matiasfreitas, thanks for raising this issue! 

Third-party integrations such as ray are maintained by their contributors, rather than the transformers team. In this case, it seems the repo id being passed is a logged step in the training. If you or anyone else in the community would like to open a PR to update, we'd be happy to review. 

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.