code: def __init__(self, comm, snapshot, replica_sets):
      assert comm is not None
      assert snapshot is not None
      self.comm = comm
      self.snapshot = snapshot
  
      # Append rank number to snapshot filename format/function
      if callable(snapshot.filename):
          filename_fun = snapshot.filename
  
          def append_rank(trainer):
              filename = filename_fun(trainer)
              return "{}.{}".format(filename, comm.rank)
  
          snapshot.filename = append_rank
  
      else:
          filename = "{}.{}".format(snapshot.filename, comm.rank)
          snapshot.filename = filename
  
      sets = _parse_replica_sets(replica_sets, comm.size)
  
      self.master = None
      self.replica_set = []
      for s in sets:
          if self.comm.rank in s:
              self.master = min(s)
              self.replica_set = s
              break
      assert self.master is not None
      assert self.comm.rank in self.replica_set
  
file_path: chainer/chainermn/extensions/_multi_node_snapshot.py
imports: import io
  from chainer.serializers import load_npz
  from chainer.serializers import save_npz
  from chainer.training.extension import Extension
  from chainer.training.extensions._snapshot import _find_latest_snapshot
label_desc: Use image node_id 1 to create a new _MultiNodeSnapshot object from inherited base classes: Extension with example: obj = _MultiNodeSnapshot(comm, snapshot, replica_sets)