Make HFDatasetDataModule a datasets.load_dataset wrapper
State: closed | Pull request: yes
Labels: name: Run CICD

# What does this PR do ?

Before:
```
dataset = load_dataset("rajpurkar/squad", split="train")
datamodule = llm.HFDatasetDataModule(dataset, pad_token_id=tokenizer.eos_token_id)
```

After:
```
datamodule = llm.HFDatasetDataModule("rajpurkar/squad", split="train", pad_token_id=tokenizer.eos_token_id)
```

Some additional use-cases:

- Load multiple partitions:
```
datamodule = llm.HFDatasetDataModule("rajpurkar/squad", split=["train", "validation"], pad_token_id=tokenizer.eos_token_id)
```

- Custom collate-fn:
```
def my_collate_fn(examples):
    ....
datamodule = llm.HFDatasetDataModule("rajpurkar/squad", split=["train", "validation"], collate_fn=my_collate_fn)
```

- Custom map function:
```
datamodule = llm.HFDatasetDataModule("rajpurkar/squad", split="train", pad_token_id=tokenizer.eos_token_id)
datamodule.map(formatting_prompts_func, batched=False, batch_size=2)
```
Instead of calling `.map` on the dataset we call it on the datamodule (which forwards it to the dataset).

**Note:** We expect the user to take appropriate care so that the keys in the returned batch (dict of tensors) matches the arguments of the downstream model.

**Collection**: LLM

# Changelog 
- Add specific line by line info of high level changes in this PR.

# Usage
* You can potentially add a usage example below

```python
# Add a code snippet demonstrating how to use this 
```

# GitHub Actions CI

The Jenkins CI system has been replaced by GitHub Actions self-hosted runners.

The GitHub Actions CI will run automatically when the "Run CICD" label is added to the PR.
To re-run CI remove and add the label again.
To run CI on an untrusted fork, a NeMo user with write access must first click "Approve and run".

# Before your PR is "Ready for review"
**Pre checks**:
- [ ] Make sure you read and followed [Contributor guidelines](https://github.com/NVIDIA/NeMo/blob/main/CONTRIBUTING.md)
- [ ] Did you write any new necessary tests?
- [ ] Did you add or update any necessary documentation?
- [ ] Does the PR affect components that are optional to install? (Ex: Numba, Pynini, Apex etc)
  - [ ] Reviewer: Does the PR have correct import guards for all optional libraries?
  
**PR Type**:
- [ ] New Feature
- [ ] Bugfix
- [ ] Documentation

If you haven't finished some of the above items you can still open "Draft" PR.


## Who can review?

Anyone in the community is free to review the PR once the checks have passed. 
[Contributor guidelines](https://github.com/NVIDIA/NeMo/blob/main/CONTRIBUTING.md) contains specific people who can review PRs to various areas.

# Additional Information
* Related to # (issue)


datamodule = llm.HFDatasetDataModule("rajpurkar/squad", split="train", pad_token_id=tokenizer.eos_token_id) - this solution enforces using a particular dataset split, 

looking into finetune_default:
```
 # datamodule = run.Config(llm.SquadDataModule, seq_length=2048, global_batch_size=128, micro_batch_size=1)
```

no split is provided and the the datamodule is able to provide both train and validation dataloaders so that later

```
recipe.trainer.val_check_interval = 100
```

can control whether validation should be active or not.

Hi @danielkorzekwa I would expect the `split` argument to be able to handle split selection, for example, passing a list of splits you want (e.g. `split=['train', 'test']`).

Please let me know if that does not work.

<!-- pylint-output-strict-mode-false -->

beep boop 🤖: 🙏 The following files have warnings. In case you are familiar with these, please try helping us to improve the code base.

---

Your code was analyzed with PyLint. The following annotations have been identified:

```
************* Module hf
examples/llm/peft/hf.py:25:0: C0301: Line too long (184/119) (line-too-long)
examples/llm/peft/hf.py:74:0: C0301: Line too long (162/119) (line-too-long)
examples/llm/peft/hf.py:21:0: C0116: Missing function or method docstring (missing-function-docstring)
************* Module nemo.collections.llm.gpt.data.api
nemo/collections/llm/gpt/data/api.py:26:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/data/api.py:32:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/data/api.py:38:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/data/api.py:44:0: C0116: Missing function or method docstring (missing-function-docstring)
************* Module nemo.collections.llm.gpt.data.hf_dataset
nemo/collections/llm/gpt/data/hf_dataset.py:161:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/data/hf_dataset.py:187:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/data/hf_dataset.py:213:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/data/hf_dataset.py:217:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/data/hf_dataset.py:221:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/data/hf_dataset.py:224:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/data/hf_dataset.py:227:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/data/hf_dataset.py:230:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/data/hf_dataset.py:233:4: C0116: Missing function or method docstring (missing-function-docstring)
************* Module nemo.collections.llm.t5.model.t5
nemo/collections/llm/t5/model/t5.py:45:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/t5/model/t5.py:98:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/t5/model/t5.py:111:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/t5/model/t5.py:123:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/t5/model/t5.py:135:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/t5/model/t5.py:143:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/llm/t5/model/t5.py:174:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/t5/model/t5.py:229:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/llm/t5/model/t5.py:238:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/llm/t5/model/t5.py:246:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/llm/t5/model/t5.py:264:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/t5/model/t5.py:268:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/t5/model/t5.py:291:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/t5/model/t5.py:294:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/t5/model/t5.py:297:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/t5/model/t5.py:301:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/t5/model/t5.py:306:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/t5/model/t5.py:328:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/t5/model/t5.py:335:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/t5/model/t5.py:37:4: W0611: Unused import transformer_engine (unused-import)

-----------------------------------
Your code has been rated at 9.13/10
```

---

Thank you for improving NeMo's documentation!

<!-- pylint-output-strict-mode-false -->

beep boop 🤖: 🙏 The following files have warnings. In case you are familiar with these, please try helping us to improve the code base.

---

Your code was analyzed with PyLint. The following annotations have been identified:

```
************* Module hf
examples/llm/peft/hf.py:25:0: C0301: Line too long (184/119) (line-too-long)
examples/llm/peft/hf.py:74:0: C0301: Line too long (162/119) (line-too-long)
examples/llm/peft/hf.py:21:0: C0116: Missing function or method docstring (missing-function-docstring)
************* Module nemo.collections.llm.gpt.data.api
nemo/collections/llm/gpt/data/api.py:26:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/data/api.py:32:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/data/api.py:38:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/data/api.py:44:0: C0116: Missing function or method docstring (missing-function-docstring)
************* Module nemo.collections.llm.gpt.data.hf_dataset
nemo/collections/llm/gpt/data/hf_dataset.py:161:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/data/hf_dataset.py:187:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/data/hf_dataset.py:213:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/data/hf_dataset.py:217:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/data/hf_dataset.py:221:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/data/hf_dataset.py:224:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/data/hf_dataset.py:227:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/data/hf_dataset.py:230:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/data/hf_dataset.py:233:4: C0116: Missing function or method docstring (missing-function-docstring)
************* Module nemo.collections.llm.t5.model.t5
nemo/collections/llm/t5/model/t5.py:45:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/t5/model/t5.py:98:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/t5/model/t5.py:111:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/t5/model/t5.py:123:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/t5/model/t5.py:135:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/t5/model/t5.py:143:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/llm/t5/model/t5.py:174:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/t5/model/t5.py:229:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/llm/t5/model/t5.py:238:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/llm/t5/model/t5.py:246:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/llm/t5/model/t5.py:264:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/t5/model/t5.py:268:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/t5/model/t5.py:291:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/t5/model/t5.py:294:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/t5/model/t5.py:297:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/t5/model/t5.py:301:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/t5/model/t5.py:306:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/t5/model/t5.py:328:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/t5/model/t5.py:335:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/t5/model/t5.py:37:4: W0611: Unused import transformer_engine (unused-import)

-----------------------------------
Your code has been rated at 9.13/10
```

---

Thank you for improving NeMo's documentation!

[🤖]: Hi @akoumpa 👋,

We wanted to let you know that a [CICD pipeline](https://github.com/NVIDIA/NeMo/actions/runs/12265154384) for this PR just finished successfully

So it might be time to merge this PR or get some approvals

I'm just a bot so I'll leave it you what to do next.

//cc @pablo-garay @ko3n1g