code: def main(params):
      """
      Main function, build mnist network, run and send result to NNI.
      """
      # Import data
      mnist = download_mnist_retry(params["data_dir"])
      print("Mnist download data done.")
      logger.debug("Mnist download data done.")
  
      # Create the model
      # Build the graph for the deep net
      mnist_network = MnistNetwork(
          channel_1_num=params["channel_1_num"],
          channel_2_num=params["channel_2_num"],
          conv_size=params["conv_size"],
          hidden_size=params["hidden_size"],
          pool_size=params["pool_size"],
          learning_rate=params["learning_rate"],
      )
      mnist_network.build_network()
      logger.debug("Mnist build network done.")
  
      # Write log
      graph_location = tempfile.mkdtemp()
      logger.debug("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.images: batch[0],
                      mnist_network.labels: batch[1],
                      mnist_network.keep_prob: 1
                      - params["dropout_rate"],
                  }
              )
  
              if i % 100 == 0:
                  test_acc = mnist_network.accuracy.eval(
                      feed_dict={
                          mnist_network.images: mnist.test.images,
                          mnist_network.labels: mnist.test.labels,
                          mnist_network.keep_prob: 1.0,
                      }
                  )
  
                  nni.report_intermediate_result(test_acc)
                  logger.debug("test accuracy %g", test_acc)
                  logger.debug("Pipe send intermediate result done.")
  
          test_acc = mnist_network.accuracy.eval(
              feed_dict={
                  mnist_network.images: mnist.test.images,
                  mnist_network.labels: mnist.test.labels,
                  mnist_network.keep_prob: 1.0,
              }
          )
  
          nni.report_final_result(test_acc)
          logger.debug("Final result is %g", test_acc)
          logger.debug("Send final result done.")
  
file_path: nni/examples/trials/mnist-tfv1/mnist.py
imports: import argparse
  import logging
  import math
  import tempfile
  import time
  import tensorflow
  from tensorflow.examples.tutorials.mnist import input_data
  import nni
label_desc: Use image node_id 6 for calling a global function with example usage: main(params) without return types