code: def load_trained_modules(idim, odim, args, interface=ASRInterface):
      """Load ASR/MT/TTS model with pre-trained weights for specified modules.
  
      Args:
          idim (int): Input dimension.
          odim (int): Output dimension.
          args Namespace: Model arguments.
          interface (ASRInterface|MTInterface|TTSInterface): Model interface.
  
      Return:
          main_model (torch.nn.Module): Model with pre-initialized weights.
  
      """
  
      def print_new_keys(state_dict, modules, model_path):
          logging.info(f"Loading {modules} from model: {model_path}")
  
          for k in state_dict.keys():
              logging.warning(f"Overriding module {k}")
  
      enc_model_path = args.enc_init
      dec_model_path = args.dec_init
      enc_modules = args.enc_init_mods
      dec_modules = args.dec_init_mods
  
      model_class = dynamic_import(args.model_module)
      main_model = model_class(idim, odim, args)
      assert isinstance(main_model, interface)
  
      main_state_dict = main_model.state_dict()
      logging.warning("Model(s) found for pre-initialization.")
  
      for model_path, modules in [
          (enc_model_path, enc_modules),
          (dec_model_path, dec_modules),
      ]:
          if model_path is not None:
              if os.path.isfile(model_path):
                  model_state_dict = get_trained_model_state_dict(
                      model_path, "transducer" in args.model_module
                  )
                  modules = filter_modules(model_state_dict, modules)
  
                  partial_state_dict = get_partial_state_dict(
                      model_state_dict, modules
                  )
  
                  if partial_state_dict:
                      if transfer_verification(
                          main_state_dict, partial_state_dict, modules
                      ):
                          print_new_keys(
                              partial_state_dict, modules, model_path
                          )
                          main_state_dict.update(partial_state_dict)
              else:
                  logging.error(
                      f"Specified model was not found: {model_path}"
                  )
                  exit(1)
  
      main_model.load_state_dict(main_state_dict)
  
      return main_model
  
file_path: espnet/espnet/asr/pytorch_backend/asr_init.py
imports: import logging
  import os
  import re
  from collections import OrderedDict
  import torch
  from espnet.asr.asr_utils import get_model_conf, torch_load
  from espnet.nets.asr_interface import ASRInterface
  from espnet.nets.mt_interface import MTInterface
  from espnet.nets.pytorch_backend.transducer.utils import custom_torch_load
  from espnet.nets.tts_interface import TTSInterface
  from espnet.utils.dynamic_import import dynamic_import
label_desc: Use image node_id 9 for calling a global function with example usage: load_trained_modules(idim, odim, args, interface) and returns: main_model