class_docstr: Base class for encoder decoder CTC-based models.
docstr: Changes vocabulary used during CTC decoding process. Use this method when fine-tuning on from pre-trained model.
  This method changes only decoder and leaves encoder and pre-processing modules unchanged. For example, you would
  use it if you want to use pretrained encoder when fine-tuning on a data in another language, or when you'd need
  model to learn capitalization, punctuation and/or special characters.
  
  If new_vocabulary == self.decoder.vocabulary then nothing will be changed.
  
  Args:
  
      new_vocabulary: list with new vocabulary. Must contain at least 2 elements. Typically,             this is target alphabet.
  
  Returns: None
docstr_tok: ["Changes","vocabulary","used","during","CTC","decoding","process",".","Use","this","method","when","fine-tuning","on","from","pre-trained","model",".","This","method","changes","only","decoder","and","leaves","encoder","and","pre-processing","modules","unchanged",".","For","example",",","you","would","use","it","if","you","want","to","use","pretrained","encoder","when","fine-tuning","on","a","data","in","another","language",",","or","when","you","'d","need","model","to","learn","capitalization",",","punctuation","and\/or","special","characters",".","If","new_vocabulary","==","self.decoder.vocabulary","then","nothing","will","be","changed",".","Args",":","new_vocabulary",":","list","with","new","vocabulary",".","Must","contain","at","least","2","elements",".","Typically",",","this","is","target","alphabet",".","Returns",":","None"]
code: def change_vocabulary(
      self,
      new_vocabulary: List[str],
      decoding_cfg: Optional[DictConfig] = None,
  ):
      """
          Changes vocabulary used during CTC decoding process. Use this method when fine-tuning on from pre-trained model.
          This method changes only decoder and leaves encoder and pre-processing modules unchanged. For example, you would
          use it if you want to use pretrained encoder when fine-tuning on a data in another language, or when you'd need
          model to learn capitalization, punctuation and/or special characters.
  
          If new_vocabulary == self.decoder.vocabulary then nothing will be changed.
  
          Args:
  
              new_vocabulary: list with new vocabulary. Must contain at least 2 elements. Typically, \
              this is target alphabet.
  
          Returns: None
  
          """
      if self.decoder.vocabulary == new_vocabulary:
          logging.warning(
              f"Old {self.decoder.vocabulary} and new {new_vocabulary} match. Not changing anything."
          )
      else:
          if new_vocabulary is None or len(new_vocabulary) == 0:
              raise ValueError(
                  f"New vocabulary must be non-empty list of chars. But I got: {new_vocabulary}"
              )
          decoder_config = self.decoder.to_config_dict()
          new_decoder_config = copy.deepcopy(decoder_config)
          new_decoder_config["vocabulary"] = new_vocabulary
          new_decoder_config["num_classes"] = len(new_vocabulary)
  
          del self.decoder
          self.decoder = EncDecCTCModel.from_config_dict(
              new_decoder_config
          )
          del self.loss
          self.loss = CTCLoss(
              num_classes=self.decoder.num_classes_with_blank - 1,
              zero_infinity=True,
              reduction=self._cfg.get("ctc_reduction", "mean_batch"),
          )
  
          if decoding_cfg is None:
              # Assume same decoding config as before
              decoding_cfg = self.cfg.decoding
  
          # Assert the decoding config with all hyper parameters
          decoding_cls = OmegaConf.structured(CTCDecodingConfig)
          decoding_cls = OmegaConf.create(
              OmegaConf.to_container(decoding_cls)
          )
          decoding_cfg = OmegaConf.merge(decoding_cls, decoding_cfg)
  
          self.decoding = CTCDecoding(
              decoding_cfg=decoding_cfg,
              vocabulary=OmegaConf.to_container(
                  self.decoder.vocabulary
              ),
          )
  
          self.wer = WER(
              decoding=self.decoding,
              use_cer=self._cfg.get("use_cer", False),
              dist_sync_on_step=True,
              log_prediction=self._cfg.get("log_prediction", False),
          )
  
          # Update config
          with open_dict(self.cfg.decoder):
              self._cfg.decoder = new_decoder_config
  
          with open_dict(self.cfg.decoding):
              self.cfg.decoding = decoding_cfg
  
          ds_keys = ["train_ds", "validation_ds", "test_ds"]
          for key in ds_keys:
              if key in self.cfg:
                  with open_dict(self.cfg[key]):
                      self.cfg[key]["labels"] = OmegaConf.create(
                          new_vocabulary
                      )
  
          logging.info(
              f"Changed decoder to output to {self.decoder.vocabulary} vocabulary."
          )
  
imports: import copy
  import json
  import os
  import tempfile
  from math import ceil
  from typing import Dict, List, Optional, Union
  import torch
  from omegaconf import DictConfig, OmegaConf, open_dict
  from pytorch_lightning import Trainer
  from tqdm.auto import tqdm
  from nemo.collections.asr.data import audio_to_text_dataset
  from nemo.collections.asr.data.audio_to_text_dali import AudioToCharDALIDataset, DALIOutputs
  from nemo.collections.asr.data.audio_to_text_lhotse import LhotseSpeechToTextBpeDataset
  from nemo.collections.asr.losses.ctc import CTCLoss
  from nemo.collections.asr.metrics.wer import WER
  from nemo.collections.asr.models.asr_model import ASRModel, ExportableEncDecModel
  from nemo.collections.asr.parts.mixins import ASRModuleMixin, InterCTCMixin
  from nemo.collections.asr.parts.submodules.ctc_decoding import CTCDecoding, CTCDecodingConfig
  from nemo.collections.asr.parts.utils.audio_utils import ChannelSelectorType
  from nemo.collections.common.data.lhotse import get_lhotse_dataloader_from_config
  from nemo.collections.common.parts.preprocessing.parsers import make_parser
  from nemo.core.classes.common import PretrainedModelInfo, typecheck
  from nemo.core.classes.mixins import AccessMixin
  from nemo.core.neural_types import AudioSignal, LabelsType, LengthsType, LogprobsType, NeuralType, SpectrogramType
  from nemo.utils import logging
label_desc: Use image node_id 3 for calling the EncDecCTCModel obj's underlying member method code with example usage: obj.change_vocabulary(new_vocabulary, decoding_cfg) without return types