code: def image_to_tf_summary_value(image, tag):
      """Converts a NumPy image to a tf.Summary.Value object.
  
      Args:
        image: 3-D NumPy array.
        tag: name for tf.Summary.Value for display in tensorboard.
      Returns:
        image_summary: A tf.Summary.Value object.
      """
      curr_image = np.asarray(image, dtype=np.uint8)
      height, width, n_channels = curr_image.shape
      # If monochrome image, then reshape to [height, width]
      if n_channels == 1:
          curr_image = np.reshape(curr_image, [height, width])
      s = io.BytesIO()
      matplotlib_pyplot().imsave(s, curr_image, format="png")
      img_sum = tf.Summary.Image(
          encoded_image_string=s.getvalue(),
          height=height,
          width=width,
          colorspace=n_channels,
      )
      return tf.Summary.Value(tag=tag, image=img_sum)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import io
  import os
  import numpy
  from tensor2tensor.data_generators import generator_utils
  from tensor2tensor.data_generators import problem
  from tensor2tensor.data_generators import text_encoder
  from tensor2tensor.layers import common_layers
  from tensor2tensor.layers import modalities
  from tensor2tensor.utils import contrib
  from tensor2tensor.utils import metrics
  import tensorflow.compat.v1
label_desc: Use image node_id 2 for calling a global function with example usage: image_to_tf_summary_value(image, tag) and returns: tf