code: def variable_summaries(var, name, collection_key):
      """Attach a lot of summaries to a Tensor (for TensorBoard visualization).
  
      Args:
          - var: Tensor for variable from which we want to log.
          - name: Variable name.
          - collection_key: Collection to save the summary to, can be any key of
            `VAR_LOG_LEVELS`.
      """
      if collection_key not in VAR_LOG_LEVELS.keys():
          raise ValueError(
              '"{}" not in `VAR_LOG_LEVELS`'.format(collection_key)
          )
      collections = VAR_LOG_LEVELS[collection_key]
  
      with tf.name_scope(name):
          mean = tf.reduce_mean(var)
          tf.summary.scalar("mean", mean, collections)
          num_params = tf.reduce_prod(tf.shape(var))
          tf.summary.scalar("num_params", num_params, collections)
          with tf.name_scope("stddev"):
              stddev = tf.sqrt(tf.reduce_mean(tf.square(var - mean)))
          tf.summary.scalar("stddev", stddev, collections)
          tf.summary.scalar("max", tf.reduce_max(var), collections)
          tf.summary.scalar("min", tf.reduce_min(var), collections)
          tf.summary.histogram("histogram", var, collections)
          tf.summary.scalar(
              "sparsity", tf.nn.zero_fraction(var), collections
          )
  
imports: import tensorflow
label_desc: Use image node_id 1 for calling a global function with example usage: variable_summaries(var, name, collection_key) without return types