def summarize_variables(variables=None):
  """Logs a summary of variable information.

  This function groups Variables by dtype and prints out the number of Variables
  and the total number of scalar values for each datatype, as well as the total
  memory consumed.

  For Variables of type tf.string, the memory usage cannot be accurately
  calculated from the Graph as the memory requirements change based on what
  strings are actually stored, which can only be determined inside a session.
  In this case, the amount of memory used to stored the pointers to the strings
  is logged, along with a warning.

  Args:
    variables: iterable of variables; if not provided, then all variables
      (in the default graph) are summarized.
  """

  variable_counts = count_variables_by_type(variables=variables)
  total_num_scalars = 0
  total_num_bytes = 0

  # Sort by string representation of type name, so output is deterministic.
  for dtype in sorted(variable_counts,
                      key=lambda dtype: "%r" % dtype):
    var_info_for_type = variable_counts[dtype]
    num_bytes = var_info_for_type["num_scalars"] * dtype.size
    total_num_scalars += var_info_for_type["num_scalars"]
    total_num_bytes += num_bytes
    tf.logging.info("%r: %d variables comprising %d scalars, %s",
                    dtype, var_info_for_type["num_variables"],
                    var_info_for_type["num_scalars"],
                    _num_bytes_to_human_readable(num_bytes))
Logs a summary of variable information.

  This function groups Variables by dtype and prints out the number of Variables
  and the total number of scalar values for each datatype, as well as the total
  memory consumed.

  For Variables of type tf.string, the memory usage cannot be accurately
  calculated from the Graph as the memory requirements change based on what
  strings are actually stored, which can only be determined inside a session.
  In this case, the amount of memory used to stored the pointers to the strings
  is logged, along with a warning.

  Args:
    variables: iterable of variables; if not provided, then all variables
      (in the default graph) are summarized.