code: def get_trained_model_state_dict(model_path, new_is_transducer):
      """Extract the trained model state dict for pre-initialization.
  
      Args:
          model_path (str): Path to trained model.
          new_is_transducer (bool): Whether the new model is Transducer-based.
  
      Return:
          (Dict): Trained model state dict.
  
      """
      logging.info(f"Reading model parameters from {model_path}")
  
      conf_path = os.path.join(
          os.path.dirname(model_path), "model.json"
      )
  
      if "rnnlm" in model_path:
          return get_lm_state_dict(torch.load(model_path))
  
      idim, odim, args = get_model_conf(model_path, conf_path)
  
      if hasattr(args, "model_module"):
          model_module = args.model_module
      else:
          model_module = "espnet.nets.pytorch_backend.e2e_asr:E2E"
  
      model_class = dynamic_import(model_module)
      model = model_class(idim, odim, args)
      torch_load(model_path, model)
  
      assert (
          isinstance(model, MTInterface)
          or isinstance(model, ASRInterface)
          or isinstance(model, TTSInterface)
      )
  
      if new_is_transducer and "transducer" not in args.model_module:
          return create_transducer_compatible_state_dict(
              model.state_dict(),
              args.etype,
              args.eunits,
          )
  
      return model.state_dict()
  
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 8 for calling a global function with example usage: get_trained_model_state_dict(model_path, new_is_transducer) and returns: model, get_lm_state_dict, create_transducer_compatible_state_dict