code: def summarize_tensor(tensor, tag=None):
      """Summarize a tensor using a suitable summary type.
  
      This function adds a summary op for `tensor`. The type of summary depends on
      the shape of `tensor`. For scalars, a `scalar_summary` is created, for all
      other tensors, `histogram_summary` is used.
  
      Args:
        tensor: The tensor to summarize
        tag: The tag to use, if None then use tensor's op's name.
  
      Returns:
        The summary op created or None for string tensors.
      """
      # Skips string tensors and boolean tensors (not handled by the summaries).
      if (
          tensor.dtype.is_compatible_with(dtypes.string)
          or tensor.dtype.base_dtype == dtypes.bool
      ):
          return None
  
      if tensor.get_shape().ndims == 0:
          # For scalars, use a scalar summary.
          return _add_scalar_summary(tensor, tag)
      else:
          # We may land in here if the rank is still unknown. The histogram won't
          # hurt if this ends up being a scalar.
          return _add_histogram_summary(tensor, tag)
  
file_path: tensornets/tensornets/contrib_layers/summaries.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import functools
  import re
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.ops import standard_ops
  from tensorflow.python.summary import summary
label_desc: Use image node_id 4 for calling a global function with example usage: summarize_tensor(tensor, tag) and returns: None, _add_scalar_summary, _add_histogram_summary