code: def example_length(example):
      length = 0
      # Length of the example is the maximum length of the feature lengths
      for _, v in sorted(six.iteritems(example)):
          # For images the sequence length is the size of the spatial dimensions.
          feature_length = tf.shape(v)[0]
          if len(v.get_shape()) > 2:
              feature_length = tf.shape(v)[0] * tf.shape(v)[1]
          length = tf.maximum(length, feature_length)
      return length
  
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 2 for calling a global function with example usage: example_length(example) and returns: length