code: def torch_resume(snapshot_path, trainer):
      """Resume from snapshot for pytorch.
  
      Args:
          snapshot_path (str): Snapshot file path.
          trainer (chainer.training.Trainer): Chainer's trainer instance.
  
      """
      from chainer.serializers import NpzDeserializer
  
      # load snapshot
      snapshot_dict = torch.load(
          snapshot_path, map_location=lambda storage, loc: storage
      )
  
      # restore trainer states
      d = NpzDeserializer(snapshot_dict["trainer"])
      d.load(trainer)
  
      # restore model states
      if hasattr(trainer.updater.model, "model"):
          # (for TTS model)
          if hasattr(trainer.updater.model.model, "module"):
              trainer.updater.model.model.module.load_state_dict(
                  snapshot_dict["model"]
              )
          else:
              trainer.updater.model.model.load_state_dict(
                  snapshot_dict["model"]
              )
      else:
          # (for ASR model)
          if hasattr(trainer.updater.model, "module"):
              trainer.updater.model.module.load_state_dict(
                  snapshot_dict["model"]
              )
          else:
              trainer.updater.model.load_state_dict(
                  snapshot_dict["model"]
              )
  
      # retore optimizer states
      trainer.updater.get_optimizer("main").load_state_dict(
          snapshot_dict["optimizer"]
      )
  
      # delete opened snapshot
      del snapshot_dict
  
imports: import argparse
  import copy
  import json
  import logging
  import os
  import shutil
  import tempfile
  import numpy
  import torch
label_desc: Use image node_id 15 for calling a global function with example usage: torch_resume(snapshot_path, trainer) without return types