code: def _prepare_multinode_snapshot(n, result):
      n_units = 100
      batchsize = 10
      comm = create_communicator("naive")
      model = L.Classifier(MLP(n_units, 10))
      optimizer = chainermn.create_multi_node_optimizer(
          chainer.optimizers.Adam(), comm
      )
      optimizer.setup(model)
  
      if comm.rank == 0:
          train, _ = chainer.datasets.get_mnist()
      else:
          train, _ = None, None
  
      train = chainermn.scatter_dataset(train, comm, shuffle=True)
      train_iter = chainer.iterators.SerialIterator(train, batchsize)
  
      updater = StandardUpdater(train_iter, optimizer)
      trainer = Trainer(updater, out=result)
  
      snapshot = extensions.snapshot(target=updater, autoload=True)
      replica_sets = []
      mn_snapshot = multi_node_snapshot(comm, snapshot, replica_sets)
      mn_snapshot.initialize(trainer)
      for _ in range(n):
          updater.update()
  
      return updater, mn_snapshot, trainer
  
imports: import mock
  import tempfile
  import pytest
  import chainer
  import chainer.links
  import chainer.functions
  from chainer.training import extensions
  from chainer.training import StandardUpdater
  from chainer.training import Trainer
  import chainermn
  from chainermn import create_communicator
  from chainermn.extensions import multi_node_snapshot
  from chainermn.extensions import _multi_node_snapshot
label_desc: Use image node_id 5 for calling a global function with example usage: _prepare_multinode_snapshot(n, result) and returns: updater,  mn_snapshot,  trainer