code: def _summarize_features(features, num_shards=1):
      with tf.name_scope("input_stats"):
          for k, v in six.iteritems(features):
              if isinstance(v, tf.Tensor) and v.get_shape().ndims > 1:
                  tf.summary.scalar(
                      "%s_batch" % k, tf.shape(v)[0] // num_shards
                  )
                  tf.summary.scalar("%s_length" % k, tf.shape(v)[1])
                  nonpadding = tf.to_float(tf.not_equal(v, 0))
                  nonpadding_tokens = tf.reduce_sum(nonpadding)
                  tf.summary.scalar(
                      "%s_nonpadding_tokens" % k, nonpadding_tokens
                  )
                  tf.summary.scalar(
                      "%s_nonpadding_fraction" % k,
                      tf.reduce_mean(nonpadding),
                  )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import functools
  import multiprocessing
  import random
  import six
  from six.moves import range
  from tensor2tensor.utils import contrib
  from tensor2tensor.utils import mlperf_log
  import tensorflow.compat.v1
  from tensorflow.compat.v1 import estimator
label_desc: Use image node_id 10 for calling a global function with example usage: _summarize_features(features, num_shards) without return types