code: def custom_torch_load(
      model_path: str, model: torch.nn.Module, training: bool = True
  ):
      """Load Transducer model with training-only modules and parameters removed.
  
      Args:
          model_path: Model path.
          model: Transducer model.
  
      """
      if "snapshot" in os.path.basename(model_path):
          model_state_dict = torch.load(
              model_path, map_location=lambda storage, loc: storage
          )["model"]
      else:
          model_state_dict = torch.load(
              model_path, map_location=lambda storage, loc: storage
          )
  
      if not training:
          task_keys = (
              "mlp",
              "ctc_lin",
              "kl_div",
              "lm_lin",
              "error_calculator",
          )
  
          model_state_dict = {
              k: v
              for k, v in model_state_dict.items()
              if not any(mod in k for mod in task_keys)
          }
  
      model.load_state_dict(model_state_dict)
  
      del model_state_dict
  
file_path: espnet/espnet/nets/pytorch_backend/transducer/utils.py
imports: import os
  from typing import Any, Dict, List, Optional, Union
  import numpy
  import torch
  from espnet.nets.pytorch_backend.nets_utils import pad_list
  from espnet.nets.transducer_decoder_interface import ExtendedHypothesis, Hypothesis
label_desc: Use image node_id 13 for calling a global function with example usage: custom_torch_load(model_path, model, training) without return types