code: def run(logdir, session_id, hparams, group_name):
      """Runs a temperature simulation.
  
      This will simulate an object at temperature `initial_temperature`
      sitting at rest in a large room at temperature `ambient_temperature`.
      The object has some intrinsic `heat_coefficient`, which indicates
      how much thermal conductivity it has: for instance, metals have high
      thermal conductivity, while the thermal conductivity of water is low.
  
      Over time, the object's temperature will adjust to match the
      temperature of its environment. We'll track the object's temperature,
      how far it is from the room's temperature, and how much it changes at
      each time step.
  
      Arguments:
        logdir: the top-level directory into which to write summary data
        session_id: an id for the session.
        hparams: A dictionary mapping a hyperparameter name to its value.
        group_name: an id for the session group this session belongs to.
      """
      tf.reset_default_graph()
      tf.set_random_seed(0)
  
      initial_temperature = hparams["initial_temperature"]
      ambient_temperature = hparams["ambient_temperature"]
      heat_coefficient = HEAT_COEFFICIENTS[hparams["material"]]
      session_dir = os.path.join(logdir, session_id)
      writer = tf.summary.FileWriter(session_dir)
      writer.add_summary(
          summary.session_start_pb(
              hparams=hparams, group_name=group_name
          )
      )
      writer.flush()
      with tf.name_scope("temperature"):
          # Create a mutable variable to hold the object's temperature, and
          # create a scalar summary to track its value over time. The name of
          # the summary will appear as 'temperature/current' due to the
          # name-scope above.
          temperature = tf.Variable(
              tf.constant(initial_temperature), name="temperature"
          )
          scalar_summary.op(
              "current",
              temperature,
              display_name="Temperature",
              description="The temperature of the object under "
              "simulation, in Kelvins.",
          )
  
          # Compute how much the object's temperature differs from that of its
          # environment, and track this, too: likewise, as
          # 'temperature/difference_to_ambient'.
          ambient_difference = temperature - ambient_temperature
          scalar_summary.op(
              "difference_to_ambient",
              ambient_difference,
              display_name="Difference to ambient temperature",
              description=(
                  "The difference between the ambient "
                  "temperature and the temperature of the "
                  "object under simulation, in Kelvins."
              ),
          )
  
      # Newton suggested that the rate of change of the temperature of an
      # object is directly proportional to this `ambient_difference` above,
      # where the proportionality constant is what we called the heat
      # coefficient. But in real life, not everything is quite so clean, so
      # we'll add in some noise. (The value of 50 is arbitrary, chosen to
      # make the data look somewhat interesting. :-) )
      noise = 50 * tf.random.normal([])
      delta = -heat_coefficient * (ambient_difference + noise)
      scalar_summary.op(
          "delta",
          delta,
          description="The change in temperature from the previous "
          "step, in Kelvins.",
      )
  
      # Collect all the scalars that we want to keep track of.
      summ = tf.summary.merge_all()
  
      # Now, augment the current temperature by this delta that we computed,
      # blocking the assignment on summary collection to avoid race conditions
      # and ensure that the summary always reports the pre-update value.
      with tf.control_dependencies([summ]):
          update_step = temperature.assign_add(delta)
  
      sess = tf.Session()
      sess.run(tf.global_variables_initializer())
      for step in range(FLAGS.num_steps):
          # By asking TensorFlow to compute the update step, we force it to
          # change the value of the temperature variable. We don't actually
          # care about this value, so we discard it; instead, we grab the
          # summary data computed along the way.
          (s, _) = sess.run([summ, update_step])
          if (step % FLAGS.summary_freq) == 0:
              writer.add_summary(s, global_step=step)
      writer.add_summary(summary.session_end_pb(api_pb2.STATUS_SUCCESS))
      writer.close()
  
file_path: tensorboard/tensorboard/plugins/hparams/hparams_minimal_demo.py
imports: import hashlib
  import math
  import os.path
  import shutil
  import tensorflow.compat.v1
  from absl import flags
  from absl import app
  from google.protobuf import struct_pb2
  from tensorboard.plugins.scalar import summary
  from tensorboard.plugins.hparams import api_pb2
  from tensorboard.plugins.hparams import summary
label_desc: Use image node_id 4 for calling a global function with example usage: run(logdir, session_id, hparams, group_name) without return types