.nemo export to .onnx error after updating from tags/v1.21.0 to tags/v1.22.0
State: closed | Pull request: no
Labels: name: bug

name: stale

I trained a Nemo ASR model (nemo.collections.asr.models.hybrid_rnnt_ctc_bpe_models.EncDecHybridRNNTCTCBPEModel) a few weeks ago using Nemo v1.21.0 and was able to decode with the .nemo model without any issues. Since then I updated my codebase and python environment to use v1.22.0. After that I tried to go back to export some models that I trained using v1.21.0 to onnx but get an error. I have the models trained with v1.21.0 on disk and here's what I'm doing to convert them to Onnx with my v1.22.0 environment:

```
import nemo.collections.asr as nemo_asr
from nemo.collections.asr.models import EncDecHybridRNNTCTCBPEModel
from omegaconf import OmegaConf
                                                                                                                        
asr_model = nemo_asr.models.ASRModel.restore_from(restore_path=args.nemo_model)
asr_model.change_decoding_strategy(decoder_type='ctc') 
asr_model.preprocessor.featurizer.dither = 0.0
asr_model.preprocessor.featurizer.pad_to = 0
asr_model.eval()
asr_model.encoder.freeze()
asr_model.decoder.freeze()                                                                                                                        
asr_model.export(args.onnx_model)
```

and then I get an error 

```
    Traceback (most recent call last):
      File "~/.conda/envs/nemo2/lib/python3.10/site-packages/nemo/core/classes/common.py", line 485, in from_config_dict
        instance = imported_cls(cfg=config, trainer=trainer)
      File "~/.conda/envs/nemo2/lib/python3.10/site-packages/nemo/collections/asr/models/hybrid_rnnt_ctc_bpe_models.py", line 89, in __init__
        super().__init__(cfg=cfg, trainer=trainer)
      File "~/.conda/envs/nemo2/lib/python3.10/site-packages/nemo/collections/asr/models/hybrid_rnnt_ctc_models.py", line 43, in __init__
        super().__init__(cfg=cfg, trainer=trainer)
      File "~/.conda/envs/nemo2/lib/python3.10/site-packages/nemo/collections/asr/models/rnnt_models.py", line 92, in __init__
        self.decoding = RNNTDecoding(
      File "~/.conda/envs/nemo2/lib/python3.10/site-packages/nemo/collections/asr/metrics/rnnt_wer.py", line 1115, in __init__
        super(RNNTDecoding, self).__init__(
      File "~/.conda/envs/nemo2/lib/python3.10/site-packages/nemo/collections/asr/metrics/rnnt_wer.py", line 257, in __init__
        self._init_confidence(self.cfg.get('confidence_cfg', None))
      File "~/.conda/envs/nemo2/lib/python3.10/site-packages/nemo/collections/asr/parts/utils/asr_confidence_utils.py", line 339, in _init_confidence
        ConfidenceConfig() if confidence_cfg is None else ConfidenceConfig(**confidence_cfg)
    TypeError: ConfidenceConfig.__init__() got an unexpected keyword argument 'measure_cfg' 
```

Ideally, an export to onnx would be agnostic to the version of Nemo used. Is there a way to address this?

**Environment overview (please complete the following information)**

 - I'm running this on an on-prem Slurm cluster
 - OS = Ubuntu 20.04
 - Python = 3.10.12
 - Pytorch = 2.1.0
 - Nemo was installed with `pip install nemo-toolkit['all']==1.22.0`

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

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