code: def main(params):
      # Import data
      mnist = download_mnist_retry(params["data_dir"])
  
      # Create the model
      # Build the graph for the deep net
      mnist_network = MnistNetwork(params)
      mnist_network.build_network()
      print("build network done.")
  
      # Write log
      graph_location = tempfile.mkdtemp()
      # print('Saving graph to: %s' % graph_location)
      train_writer = tf.summary.FileWriter(graph_location)
      train_writer.add_graph(tf.get_default_graph())
  
      test_acc = 0.0
      with tf.Session() as sess:
          sess.run(tf.global_variables_initializer())
          for i in range(params["batch_num"]):
              batch = mnist.train.next_batch(params["batch_size"])
              mnist_network.train_step.run(
                  feed_dict={
                      mnist_network.x: batch[0],
                      mnist_network.y: batch[1],
                  }
              )
  
              if i % 100 == 0:
                  train_accuracy = mnist_network.accuracy.eval(
                      feed_dict={
                          mnist_network.x: batch[0],
                          mnist_network.y: batch[1],
                      }
                  )
                  print(
                      "step %d, training accuracy %g"
                      % (i, train_accuracy)
                  )
  
          test_acc = mnist_network.accuracy.eval(
              feed_dict={
                  mnist_network.x: mnist.test.images,
                  mnist_network.y: mnist.test.labels,
              }
          )
  
          nni.report_final_result(test_acc)
  
imports: from __future__ import absolute_import, division, print_function
  import logging
  import math
  import tempfile
  import time
  import argparse
  import tensorflow
  from tensorflow.examples.tutorials.mnist import input_data
  import nni
label_desc: Use image node_id 2 for calling a global function with example usage: main(params) without return types