code: def _create_var(name: str, value_expr: TfExpression) -> TfExpression:
      """Internal helper for creating autosummary accumulators."""
      assert not _finalized
      name_id = name.replace("/", "_")
      v = tf.cast(value_expr, _dtype)
  
      if v.shape.is_fully_defined():
          size = np.prod(v.shape.as_list())
          size_expr = tf.constant(size, dtype=_dtype)
      else:
          size = None
          size_expr = tf.reduce_prod(tf.cast(tf.shape(v), _dtype))
  
      if size == 1:
          if v.shape.ndims != 0:
              v = tf.reshape(v, [])
          v = [size_expr, v, tf.square(v)]
      else:
          v = [size_expr, tf.reduce_sum(v), tf.reduce_sum(tf.square(v))]
      v = tf.cond(
          tf.is_finite(v[1]),
          lambda: tf.stack(v),
          lambda: tf.zeros(3, dtype=_dtype),
      )
  
      with tfutil.absolute_name_scope(
          "Autosummary/" + name_id
      ), tf.control_dependencies(None):
          var = tf.Variable(
              tf.zeros(3, dtype=_dtype), trainable=False
          )  # [sum(1), sum(x), sum(x**2)]
      update_op = tf.cond(
          tf.is_variable_initialized(var),
          lambda: tf.assign_add(var, v),
          lambda: tf.assign(var, v),
      )
  
      if name in _vars:
          _vars[name].append(var)
      else:
          _vars[name] = [var]
      return update_op
  
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 1 for calling a global function with example usage: _create_var(name, value_expr) and returns: update_op