class_docstr: Base class for hybrid RNNT/CTC models.
class_docstr_tok: ["Base","class","for","hybrid","RNNT\/CTC","models","."]
docstr: Changes vocabulary used during RNNT decoding process. Use this method when fine-tuning a 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 data in another language, or when you'd need
  model to learn capitalization, punctuation and/or special characters.
  
  Args:
      new_vocabulary: list with new vocabulary. Must contain at least 2 elements. Typically,                 this is target alphabet.
      decoding_cfg: A config for the decoder, which is optional. If the decoding type
          needs to be changed (from say Greedy to Beam decoding etc), the config can be passed here.
      ctc_decoding_cfg: A config for CTC decoding, which is optional and can be used to change decoding type.
  
  Returns: None
docstr_tok: ["Changes","vocabulary","used","during","RNNT","decoding","process",".","Use","this","method","when","fine-tuning","a","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","data","in","another","language",",","or","when","you","'d","need","model","to","learn","capitalization",",","punctuation","and\/or","special","characters",".","Args",":","new_vocabulary",":","list","with","new","vocabulary",".","Must","contain","at","least","2","elements",".","Typically",",","this","is","target","alphabet",".","decoding_cfg",":","A","config","for","the","decoder",",","which","is","optional",".","If","the","decoding","type","needs","to","be","changed","(","from","say","Greedy","to","Beam","decoding","etc",")",",","the","config","can","be","passed","here",".","ctc_decoding_cfg",":","A","config","for","CTC","decoding",",","which","is","optional","and","can","be","used","to","change","decoding","type",".","Returns",":","None"]
code: def change_vocabulary(
      self,
      new_vocabulary: List[str],
      decoding_cfg: Optional[DictConfig] = None,
      ctc_decoding_cfg: Optional[DictConfig] = None,
  ):
      """
          Changes vocabulary used during RNNT decoding process. Use this method when fine-tuning a 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 data in another language, or when you'd need
          model to learn capitalization, punctuation and/or special characters.
  
          Args:
              new_vocabulary: list with new vocabulary. Must contain at least 2 elements. Typically, \
                  this is target alphabet.
              decoding_cfg: A config for the decoder, which is optional. If the decoding type
                  needs to be changed (from say Greedy to Beam decoding etc), the config can be passed here.
              ctc_decoding_cfg: A config for CTC decoding, which is optional and can be used to change decoding type.
  
          Returns: None
  
          """
      super().change_vocabulary(
          new_vocabulary=new_vocabulary, decoding_cfg=decoding_cfg
      )
  
      # set up the new tokenizer for the CTC decoder
      if hasattr(self, "ctc_decoder"):
          if self.ctc_decoder.vocabulary == new_vocabulary:
              logging.warning(
                  f"Old {self.ctc_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.ctc_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.ctc_decoder
              self.ctc_decoder = (
                  VisualEncDecHybridRNNTCTCModel.from_config_dict(
                      new_decoder_config
                  )
              )
              del self.ctc_loss
              self.ctc_loss = CTCLoss(
                  num_classes=self.ctc_decoder.num_classes_with_blank
                  - 1,
                  zero_infinity=True,
                  reduction=self.cfg.aux_ctc.get(
                      "ctc_reduction", "mean_batch"
                  ),
              )
  
              if ctc_decoding_cfg is None:
                  # Assume same decoding config as before
                  logging.info(
                      "No `ctc_decoding_cfg` passed when changing decoding strategy, using internal config"
                  )
                  ctc_decoding_cfg = self.cfg.aux_ctc.decoding
  
              # Assert the decoding config with all hyper parameters
              ctc_decoding_cls = OmegaConf.structured(CTCDecodingConfig)
              ctc_decoding_cls = OmegaConf.create(
                  OmegaConf.to_container(ctc_decoding_cls)
              )
              ctc_decoding_cfg = OmegaConf.merge(
                  ctc_decoding_cls, ctc_decoding_cfg
              )
  
              self.ctc_decoding = CTCDecoding(
                  decoding_cfg=ctc_decoding_cfg,
                  vocabulary=self.ctc_decoder.vocabulary,
              )
  
              self.ctc_wer = WER(
                  decoding=self.ctc_decoding,
                  use_cer=self.ctc_wer.use_cer,
                  log_prediction=self.ctc_wer.log_prediction,
                  dist_sync_on_step=True,
              )
  
              # Update config
              with open_dict(self.cfg.aux_ctc):
                  self.cfg.aux_ctc.decoding = ctc_decoding_cfg
  
              with open_dict(self.cfg.aux_ctc):
                  self.cfg.aux_ctc.decoder = new_decoder_config
  
              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 the tokenizer of the CTC decoder to {self.ctc_decoder.vocabulary} vocabulary."
              )
  
imports: import copy
  import json
  import os
  import tempfile
  from typing import List, Optional
  import torch
  from omegaconf import DictConfig, OmegaConf, open_dict
  from pytorch_lightning import Trainer
  from tqdm.auto import tqdm
  from nemo.collections.asr.losses.ctc import CTCLoss
  from nemo.collections.asr.metrics.wer import WER
  from nemo.collections.asr.parts.mixins import ASRBPEMixin, 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.multimodal.speech_cv.models.visual_rnnt_models import VisualEncDecRNNTModel
  from nemo.core.classes.common import PretrainedModelInfo
  from nemo.core.classes.mixins import AccessMixin
  from nemo.utils import logging, model_utils
label_desc: Use image node_id 3 for calling the VisualEncDecHybridRNNTCTCModel obj's underlying member method code with example usage: obj.change_vocabulary(new_vocabulary, decoding_cfg, ctc_decoding_cfg) without return types