code: def restore_snapshot(model, snapshot, load_fn=None):
      """Extension to restore snapshot.
  
      Returns:
          An extension function.
  
      """
      import chainer
      from chainer import training
  
      if load_fn is None:
          load_fn = chainer.serializers.load_npz
  
      @training.make_extension(trigger=(1, "epoch"))
      def restore_snapshot(trainer):
          _restore_snapshot(model, snapshot, load_fn)
  
      return restore_snapshot
  
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 1 for calling a global function with example usage: restore_snapshot(model, snapshot, load_fn) and returns: restore_snapshot