Repository: NVIDIA/NeMo

Issue:
`PunctuationCapitalizationModel` restoring from checkpoint is not working if a config field `model.common_dataset_parameters.label_vocab_dir` is set
**Describe the bug**

If model is being restored from checkpoint path from a config field `model.common_dataset_parameters.label_vocab_dir` should not be prepended to config fields `model.class_labels.punct_labels_file` and `model.class_labels.punct_labels_file`. This because in a checkpoint these labels files are in the root of a checkpoint archive.

**Steps/Code to reproduce bug**

1. Create a config provides label ids using  `model.class_labels.punct_labels_file` and `model.class_labels.punct_labels_file`.  `model.common_dataset_parameters.label_vocab_dir` should not be empty.
2. Create a `.nemo` checkpoint for a model created via the config.
3. Try to restore from the `.nemo` checkpoint.


**Expected behavior**

A restoring without errors

**Environment overview (please complete the following information)**

 - Environment location: Bare-metal
 - Method of NeMo install: `pip install nemo_toolkit[all]`

**Environment details**

If NVIDIA docker image is used you don't need to specify these.
Otherwise, please provide:
- OS version: Ubuntu 20.04.1 LTS
- PyTorch version: 1.10.2
- Python version: 3.8.12



Discussion:

Resolving patch:
diff --git a/nemo/collections/nlp/models/token_classification/punctuation_capitalization_model.py b/nemo/collections/nlp/models/token_classification/punctuation_capitalization_model.py
--- a/nemo/collections/nlp/models/token_classification/punctuation_capitalization_model.py
+++ b/nemo/collections/nlp/models/token_classification/punctuation_capitalization_model.py
@@ -638,16 +638,16 @@ def _check_label_config_parameters(self) -> None:
                 )
 
     def _extract_label_vocab_files_from_config(self) -> Tuple[Optional[Path], Optional[Path]]:
-        if self._cfg.common_dataset_parameters.label_vocab_dir is None:
-            if self._is_model_being_restored():
-                punct_label_vocab_file = self._cfg.class_labels.punct_labels_file
-                capit_label_vocab_file = self._cfg.class_labels.capit_labels_file
-            else:
-                punct_label_vocab_file, capit_label_vocab_file = None, None
+        if self._is_model_being_restored():
+            punct_label_vocab_file = self._cfg.class_labels.punct_labels_file
+            capit_label_vocab_file = self._cfg.class_labels.capit_labels_file
         else:
-            label_vocab_dir = Path(self._cfg.common_dataset_parameters.label_vocab_dir).expanduser()
-            punct_label_vocab_file = label_vocab_dir / self._cfg.class_labels.punct_labels_file
-            capit_label_vocab_file = label_vocab_dir / self._cfg.class_labels.capit_labels_file
+            if self._cfg.common_dataset_parameters.label_vocab_dir is None:
+                punct_label_vocab_file, capit_label_vocab_file = None, None
+            else:
+                label_vocab_dir = Path(self._cfg.common_dataset_parameters.label_vocab_dir).expanduser()
+                punct_label_vocab_file = label_vocab_dir / self._cfg.class_labels.punct_labels_file
+                capit_label_vocab_file = label_vocab_dir / self._cfg.class_labels.capit_labels_file
         return punct_label_vocab_file, capit_label_vocab_file
 
     def _set_label_ids(self) -> None:


Test patch: