code: def rename_state_dict(
      old_prefix: str,
      new_prefix: str,
      state_dict: Dict[str, torch.Tensor],
  ):
      """Replace keys of old prefix with new prefix in state dict."""
      # need this list not to break the dict iterator
      old_keys = [k for k in state_dict if k.startswith(old_prefix)]
      if len(old_keys) > 0:
          logging.warning(f"Rename: {old_prefix} -> {new_prefix}")
      for k in old_keys:
          v = state_dict.pop(k)
          new_k = k.replace(old_prefix, new_prefix)
          state_dict[new_k] = v
  
file_path: espnet/espnet/nets/pytorch_backend/nets_utils.py
imports: import logging
  from typing import Dict
  import numpy
  import torch
label_desc: Use image node_id 12 for calling a global function with example usage: rename_state_dict(old_prefix, new_prefix, state_dict) without return types