code: def log_variable(variable, gradient=None):
      r"""
      We introduce a function for logging a tensor variable's current state.
      It logs scalar values for the mean, standard deviation, minimum and maximum.
      Furthermore it logs a histogram of its state and (if given) of an optimization gradient.
      """
      name = variable.name.replace(":", "_")
      mean = tf.reduce_mean(input_tensor=variable)
      tfv1.summary.scalar(name="%s/mean" % name, tensor=mean)
      tfv1.summary.scalar(
          name="%s/sttdev" % name,
          tensor=tf.sqrt(
              tf.reduce_mean(input_tensor=tf.square(variable - mean))
          ),
      )
      tfv1.summary.scalar(
          name="%s/max" % name,
          tensor=tf.reduce_max(input_tensor=variable),
      )
      tfv1.summary.scalar(
          name="%s/min" % name,
          tensor=tf.reduce_min(input_tensor=variable),
      )
      tfv1.summary.histogram(name=name, values=variable)
      if gradient is not None:
          if isinstance(gradient, tf.IndexedSlices):
              grad_values = gradient.values
          else:
              grad_values = gradient
          if grad_values is not None:
              tfv1.summary.histogram(
                  name="%s/gradients" % name, values=grad_values
              )
  
imports: from __future__ import absolute_import, division, print_function
  import os
  import sys
  import absl.app
  import numpy
  import progressbar
  import shutil
  import tensorflow
  import tensorflow.compat.v1
  import time
  from datetime import datetime
  from ds_ctcdecoder import ctc_beam_search_decoder, Scorer
  from .evaluate import evaluate
  from six.moves import zip, range
  from .util.config import Config, initialize_globals
  from .util.checkpoints import load_or_init_graph_for_training, load_graph_for_evaluation, reload_best_checkpoint
  from .util.evaluate_tools import save_samples_json
  from .util.feeding import create_dataset, audio_to_features, audiofile_to_features
  from .util.flags import create_flags, FLAGS
  from .util.helpers import check_ctcdecoder_version, ExceptionBox
  from .util.logging import create_progressbar, log_debug, log_error, log_info, log_progress, log_warn
  from .util.io import open_remote, remove_remote, listdir_remote, is_remote_path, isdir_remote
label_desc: Use image node_id 12 for calling a global function with example usage: log_variable(variable, gradient) without return types