Add return_file_name in load_dataset
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/datasets/pr_6310). All of your documentation changes will be reflected on that endpoint. > Thanks for the change !
> 
> Since `return` in python often refers to what is actually returned by the function (here `load_dataset`), I think we can use another word for the parameter. Maybe name it `with_file_names`?
> 
> cc @mariosasko in case you have an opinion

I changed the argument name to your suggestion, I agree that it should be less confusing :) > Thanks! I've left some comments.
> 
> @lhoestq WDYT about returning a data file's name (the last part) instead of the full path? This way we could have the same values in the streaming and the non-streaming mode. (In the non-streaming mode, we would also have to iterate over remote files to not output the files' hash (from the HF cache))

Concerning the last part of the file name, do you have suggestions on how to do that? Because it can happen that the files are located in different folders with the same name so I am wondering what would be the way to go. Hi @lhoestq @mariosasko, I just pushed a version rebased on main I've seen some activity on the issue associated to the PR so I wonder if you are interested in keeping up the process of merging this PR. I still have the same issues as indicated in the previous comment. The original issue https://github.com/huggingface/datasets/issues/5806 is about returning the file names in order to be able to resume data loading from a checkpoint.

Data loading checkpointing has been implemented recently actually, using `torchdata` `StatefulDataloader`

See the discussion at https://github.com/huggingface/datasets/issues/5454

I'm not sure if it's worth continuing this PR then ? > The original issue #5806 is about returning the file names in order to be able to resume data loading from a checkpoint.
> 
> Data loading checkpointing has been implemented recently actually, using `torchdata` `StatefulDataloader`
> 
> See the discussion at #5454
> 
> I'm not sure if it's worth continuing this PR then ?

Thanks for your answer, I'll close the PR if now the feature already exists  :). I need this for downstream filter. People always put important information in the file name.
Proposition to fix #5806.

Added an optional parameter `return_file_name` in the dataset builder config. When set to `True`, the function will include the file name corresponding to the sample in the returned output.

There is a difference between arrow-based and folder-based datasets to return the file name:
- for arrow-based: a column is concatenated after the table is cast.
- for folder-based: `dataset.info.features` has the entry `file_name` and the original file name is passed to the `sample_metadata` dictionary. 

The difference in behavior might be a concern, also I do not know whether the `file_name` should return the original file path or the downloaded one for folder-based datasets.

I added some tests for the datasets that already had a test file.