code: def get_checkpoint_func(args):
      """
      Return closure that performs checkpointing.
      """
  
      def checkpoint_func(idx, model):
          if "RANK" not in os.environ or os.environ["RANK"] == 0:
              if args.checkpoint_folder is not None:
                  checkpoint_file = os.path.join(
                      args.checkpoint_folder, "iter_%05d.torch" % idx
                  )
                  torch.save(model, checkpoint_file)
  
      return checkpoint_func
  
file_path: CrypTen/examples/bandits/launcher.py
imports: import argparse
  import logging
  import os
  import random
  import examples.util
  import torch
  import visdom
  from examples.multiprocess_launcher import MultiProcessLauncher
  from examples.util import NoopContextManager, process_mnist_files
  from torchvision.datasets.mnist import MNIST
label_desc: Use image node_id 7 for calling a global function with example usage: get_checkpoint_func(args) and returns: checkpoint_func