Dataset 'jsonl' doesn't exist on the Hub in examples/pytorch/translation/run_translation.py
Author: mathiasesn
Pull request: no

### System Info

- `transformers` version: 4.35.0.dev0
- Platform: Linux-6.2.0-34-generic-x86_64-with-glibc2.35
- Python version: 3.10.12
- Huggingface_hub version: 0.16.4
- Safetensors version: 0.3.3
- Accelerate version: 0.24.0.dev0
- Accelerate config:    not found
- PyTorch version (GPU?): 2.1.0+cu121 (True)
- Tensorflow version (GPU?): 2.10.0 (False)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: Yes
- Using distributed or parallel set-up in script?: No

### Who can help?

@patil-suraj

### Information

- [X] The official example scripts
- [ ] 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

To reproduce the issue, follow the steps outlined below:

1. Environment Setup:

- Python >= 3.10
- pip install datasets

2. Dataset Files:

Have train.jsonl and validation.jsonl files present at the paths specified.

3. Code to Reproduce the Issue:

```python
Copy code
import datasets

# Setting data file paths
data_files = {}
data_files["train"] = "/home/mathias/translation_scripts/data/opus/huggingface/train_opus_en-da.jsonl"
data_files["validation"] = "/home/mathias/translation_scripts/data/opus/huggingface/validation_opus_en-da.jsonl"
print(data_files)

# Loading the dataset
from datasets import load_dataset
load_dataset("jsonl", data_files=data_files)
```
4. Error Message:

When running the code above, the following error message is generated:

```bash
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/mathias/.local/lib/python3.10/site-packages/datasets/load.py", line 2129, in load_dataset
    builder_instance = load_dataset_builder(
  File "/home/mathias/.local/lib/python3.10/site-packages/datasets/load.py", line 1815, in load_dataset_builder
    dataset_module = dataset_module_factory(
  File "/home/mathias/.local/lib/python3.10/site-packages/datasets/load.py", line 1508, in dataset_module_factory
    raise FileNotFoundError(
FileNotFoundError: Couldn't find a dataset script at /home/mathias/translation_scripts/jsonl/jsonl.py or any data file in the same directory. Couldn't find 'jsonl' on the Hugging Face Hub either: FileNotFoundError: Dataset 'jsonl' doesn't exist on the Hub. If the repo is private or gated, make sure to log in with `huggingface-cli login`.
```

### Expected behavior

With the following python code:

```python
data_files = {}
data_files["train"] = "path/to/train.jsonl"
data_files["validation"] = "path/to/validation.jsonl"

load_dataset("jsonl", data_files=data_files)
```

The following output should be expected:

```bash
Downloading data files: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:00<00:00, 29746.84it/s]
Extracting data files: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:00<00:00, 1740.74it/s]
Generating train split: 1000000 examples [00:00, 3119077.05 examples/s]
Generating validation split: 2000 examples [00:00, 1100578.33 examples/s]
DatasetDict({
    train: Dataset({
        features: ['translation'],
        num_rows: 1000000
    })
    validation: Dataset({
        features: ['translation'],
        num_rows: 2000
    })
})
```

Comments:
A simple fix would be to add:

```python
        if extension == "jsonl":
            extension = "json"
```

after [line 373 in examples/pytorch/translation/run_translation.py](https://github.com/huggingface/transformers/blob/4b423e607455a7aca1edc4beaa713da58e78ef0b/examples/pytorch/translation/run_translation.py#L373).

cc @lhoestq if you think the script should be udated  or if it's a dataset issue ?

`datasets` has a number of generic dataset builders: "text", "parquet", "json", "imagefolder" etc.
And the "json" builder supports both json and jsonl.

So yes the script should be updated. The fix proposed by @mathiasesn does the job !

Also if you want you can improve the variable names to do

```python
load_dataset(builder_name)
```

instead of 

```python
load_dataset(extension)
```

which is incorrect.


Nice, @mathiasesn would you like to open a pr? 

> Nice, @mathiasesn would you like to open a pr?

Yes.

PR: https://github.com/huggingface/transformers/pull/26924, @ArthurZucker and @lhoestq.

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.