code: def convert_predictions_to_image_summaries(hook_args):
      """Optionally converts images from hooks_args to image summaries.
  
      Args:
        hook_args: DecodeHookArgs namedtuple
      Returns:
        summaries: list of tf.Summary values if hook_args.decode_hpara
      """
      decode_hparams = hook_args.decode_hparams
      if not decode_hparams.display_decoded_images:
          return []
      predictions = hook_args.predictions[0]
  
      # Display ten random inputs and outputs so that tensorboard does not hang.
      all_summaries = []
      rand_predictions = np.random.choice(predictions, size=10)
      for ind, prediction in enumerate(rand_predictions):
          output_summary = image_to_tf_summary_value(
              prediction["outputs"], tag="%d_output" % ind
          )
          input_summary = image_to_tf_summary_value(
              prediction["inputs"], tag="%d_input" % ind
          )
          all_summaries.append(input_summary)
          all_summaries.append(output_summary)
      return all_summaries
  
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 3 for calling a global function with example usage: convert_predictions_to_image_summaries(hook_args) and returns: all_summaries, list