code: def _trial_summary(
      hparams, model_dir, output_dir, additional_trial_info
  ):
      """Writes a tensorboard text summary of the trial."""
  
      summaries_to_write = collections.OrderedDict()
      summaries_to_write["model_dir"] = model_dir
      summaries_to_write["command_line_args"] = " \\".join(sys.argv)
  
      tf.logging.info("Writing hparams summary: %s", hparams)
  
      hparams_dict = hparams.values()
  
      # Create a markdown table from hparams.
      header = "| Key | Value |\n| :--- | :--- |\n"
      keys = sorted(hparams_dict.keys())
      lines = [
          "| %s | %s |" % (key, str(hparams_dict[key])) for key in keys
      ]
      hparams_table = header + "\n".join(lines) + "\n"
  
      summaries_to_write["hparams"] = hparams_table
  
      summaries_to_write.update(additional_trial_info)
  
      with tf.Session() as sess:
          writer = tf.summary.FileWriter(output_dir, graph=sess.graph)
          for name, summary in summaries_to_write.items():
              tf.logging.info(
                  "Writing summary for %s: %s", name, summary
              )
              writer.add_summary(
                  tf.summary.text(
                      name,
                      tf.constant(summary, name=name),
                      collections=[],
                  ).eval()
              )
          writer.close()
  
file_path: magenta/magenta/models/onsets_frames_transcription/train_util.py
imports: import collections
  import copy
  import functools
  import random
  import sys
  import tensorflow.compat.v1
  from tensorflow.compat.v1 import estimator
  import tf_slim
label_desc: Use image node_id 1 for calling a global function with example usage: _trial_summary(hparams, model_dir, output_dir, additional_trial_info) without return types