code: def distributed_worker(outdir, gpu, mode, config):
      if gpu:
          # test with only one GPU
          C.try_set_default_device(C.gpu(0))
      else:
          # CPU sparse aggregation is not implemented, so turn it off
          # note we only need to explicitly do this when running with CPU device on a GPU build
          # For CPU build it's disabled by default
          C.cntk_py.use_sparse_gradient_aggregation_in_data_parallel_sgd(
              False
          )
  
      trainer = SimpleTrainer(mode, config)
      for batch in range(NUM_BATCHES):
          set_np_random_seed(C.Communicator.rank(), batch)
          indices = (
              np.random.random((BATCH_SIZE_PER_WORKER,))
              * (trainer.input_dim - 1)
          ).astype(np.int)
          trainer.train_minibatch(indices)
          checkpoint_file = os.path.join(outdir, mode + str(batch))
          trainer.trainer.save_checkpoint(checkpoint_file)
          trainer.trainer.restore_from_checkpoint(checkpoint_file)
  
      # save a checkpoint to force sync after last minibatch
      trainer.trainer.save_checkpoint(
          os.path.join(outdir, mode + "_last")
      )
      np.save(
          os.path.join(outdir, mode + str(C.Communicator.rank())),
          trainer.p.value,
      )
  
imports: import argparse
  import collections
  import os
  import pickle
  import pytest
  import re
  import signal
  import subprocess
  import sys
  import time
  import numpy
  import cntk
label_desc: Use image node_id 3 for calling a global function with example usage: distributed_worker(outdir, gpu, mode, config) without return types