code: def train(reader_train):
      k = 2
      worker_rank = C.Communicator.rank()
      # print out loss for each model for upto 50 times
      print_frequency_mbsize = num_minibatches // 50
      pp_G = C.logging.ProgressPrinter(
          print_frequency_mbsize, rank=worker_rank
      )
      pp_D = C.logging.ProgressPrinter(
          print_frequency_mbsize * k, rank=worker_rank
      )
  
      X_real, X_fake, Z, G_trainer, D_trainer = build_graph(
          g_input_dim, d_input_dim, pp_G, pp_D
      )
  
      input_map = {X_real: reader_train.streams.features}
  
      num_partitions = C.Communicator.num_workers()
      worker_rank = C.Communicator.rank()
      distributed_minibatch_size = minibatch_size // num_partitions
  
      for train_step in range(num_minibatches):
          # train the discriminator model for k steps
          for gen_train_step in range(k):
              Z_data = noise_sample(distributed_minibatch_size)
              X_data = reader_train.next_minibatch(
                  minibatch_size,
                  input_map,
                  num_data_partitions=num_partitions,
                  partition_index=worker_rank,
              )
  
              if X_data[X_real].num_samples == Z_data.shape[0]:
                  batch_inputs = {
                      X_real: X_data[X_real].data,
                      Z: Z_data,
                  }
                  D_trainer.train_minibatch(batch_inputs)
  
          # train the generator model for a single step
          Z_data = noise_sample(distributed_minibatch_size)
          batch_inputs = {Z: Z_data}
          G_trainer.train_minibatch(batch_inputs)
  
          G_trainer_loss = G_trainer.previous_minibatch_loss_average
  
      return Z, X_fake, G_trainer_loss
  
file_path: CNTK/Examples/Image/GAN/Basic_GAN_Distributed.py
imports: import matplotlib
  import matplotlib.pyplot
  import numpy
  import os
  import argparse
  import cntk
  import cntk.tests.test_utils
  from timeit import default_timer
label_desc: Use image node_id 6 for calling a global function with example usage: train(reader_train) and returns: Z,  X_fake,  G_trainer_loss