code: def autosummary(
      name: str,
      value: TfExpressionEx,
      passthru: TfExpressionEx = None,
      condition: TfExpressionEx = True,
  ) -> TfExpressionEx:
      """Create a new autosummary.
  
      Args:
          name:     Name to use in TensorBoard
          value:    TensorFlow expression or python value to track
          passthru: Optionally return this TF node without modifications but tack an autosummary update side-effect to this node.
  
      Example use of the passthru mechanism:
  
      n = autosummary('l2loss', loss, passthru=n)
  
      This is a shorthand for the following code:
  
      with tf.control_dependencies([autosummary('l2loss', loss)]):
          n = tf.identity(n)
      """
      tfutil.assert_tf_initialized()
      name_id = name.replace("/", "_")
  
      if tfutil.is_tf_expression(value):
          with tf.name_scope("summary_" + name_id), tf.device(
              value.device
          ):
              condition = tf.convert_to_tensor(
                  condition, name="condition"
              )
              update_op = tf.cond(
                  condition,
                  lambda: tf.group(_create_var(name, value)),
                  tf.no_op,
              )
              with tf.control_dependencies([update_op]):
                  return tf.identity(
                      value if passthru is None else passthru
                  )
  
      else:  # python scalar or numpy array
          assert not tfutil.is_tf_expression(passthru)
          assert not tfutil.is_tf_expression(condition)
          if condition:
              if name not in _immediate:
                  with tfutil.absolute_name_scope(
                      "Autosummary/" + name_id
                  ), tf.device(None), tf.control_dependencies(None):
                      update_value = tf.placeholder(_dtype)
                      update_op = _create_var(name, update_value)
                      _immediate[name] = update_op, update_value
              update_op, update_value = _immediate[name]
              tfutil.run(update_op, {update_value: value})
          return value if passthru is None else passthru
  
file_path: insightface/reconstruction/ostec/external/stylegan2/dnnlib/tflib/autosummary.py
imports: from collections import OrderedDict
  import numpy
  import tensorflow
  from tensorboard import summary
  from tensorboard.plugins.custom_scalar import layout_pb2
  from .None import tfutil
  from .tfutil import TfExpression
  from .tfutil import TfExpressionEx
label_desc: Use image node_id 2 for calling a global function with example usage: autosummary(name, value, passthru, condition) and returns: unknown, tf