code: def tensors_to_images(input_files, image_shape, add_softmax):
      with tf.Graph().as_default():
          input = tf.placeholder(
              tf.float32, shape=image_shape, name="input"
          )
          output = tf.placeholder(tf.string, name="output_file")
          if add_softmax:
              input = tf.nn.softmax(input)
          # use the second channel if it is gray image
          if image_shape[2] == 2:
              _, input = tf.split(input, 2, axis=2)
          tensor_data = tf.image.convert_image_dtype(
              input, tf.uint8, saturate=True
          )
          image_data = tf.image.encode_jpeg(tensor_data, quality=100)
          writer = tf.write_file(
              output, image_data, name="output_writer"
          )
  
          with tf.Session() as sess:
              for i in range(len(input_files)):
                  input_data = np.fromfile(
                      input_files[i], dtype=np.float32
                  ).reshape(image_shape)
                  output_file = os.path.join(
                      FLAGS.output_dir,
                      os.path.splitext(
                          os.path.basename(input_files[i])
                      )[0]
                      + ".jpg",
                  )
                  sess.run(
                      writer,
                      feed_dict={
                          "input:0": input_data,
                          "output_file:0": output_file,
                      },
                  )
  
file_path: mace/tools/image/tensor_to_image.py
imports: import argparse
  import os
  import sys
  import six
  import numpy
  import tensorflow
label_desc: Use image node_id 2 for calling a global function with example usage: tensors_to_images(input_files, image_shape, add_softmax) without return types