Use `get_vocab` method instead of `vocab`
State: closed | Pull request: yes
Labels: name: stale

name: common

# What does this PR do ?

This PR fixes the issue of missing vocab property for NeMo AutoTokenizer.

Currently, NeMo's AutoTokenizer obtains a list of vocabulary from `tokenizer.vocab`.
However, it can be problematic for the following reasons:

- the property is sometimes missing for certain type of HuggingFace tokenizers.
- the property is not documented in Huggingface Transformers Library.

For example, non-fast version of T5Tokenizer does not seem to have `vocab` as follows:

```
In [8]: assert getattr(AutoTokenizer.from_pretrained('google-t5/t5-base'), "vocab") # This one is OK
In [9]: assert getattr(AutoTokenizer.from_pretrained('google-t5/t5-base', use_fast=False), "vocab") # Not OK
…
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[9], line 1
----> 1 assert getattr(AutoTokenizer.from_pretrained('google-t5/t5-base', use_fast=False), "vocab")

AttributeError: 'T5Tokenizer' object has no attribute 'vocab'
```
This can be a problem for `GPTSFTChatDataset` because it assumes that a given tokenizer has a`vocab` property.

https://github.com/NVIDIA/NeMo/blob/7d3d9ac3b1aecf5786b5978a0c1e574701473c62/nemo/collections/nlp/data/language_modeling/megatron/gpt_sft_chat_dataset.py#L313

This PR renames a reference to `vocab`property to `get_vocab` method. 
I believe that this method also returns a list of vocabulary in a same manner as `vocab` property.
Thus, existing tokenizers would not be affected.

**Collection**: [Note which collection this PR will affect]

This PR may affect tokenizer component.

# Changelog 

renamed `vocab` to `get_vocab`

# Usage

n/a

# 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**:
- [x] Make sure you read and followed [Contributor guidelines](https://github.com/NVIDIA/NeMo/blob/main/CONTRIBUTING.md)
- [x] Did you write any new necessary tests?
- [x] Did you add or update any necessary documentation?
- [x] 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
- [x] 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

n/a


@ericharper  @titu1994  @blisc @okuchaiev Would you please review my PR? 

This PR is stale because it has been open for 14 days with no activity. Remove stale label or comment or update or this will be closed in 7 days.

This PR was closed because it has been inactive for 7 days since being marked as stale.