code: def _infer_sizes(example_features, labels):
      """Infers batch_size, list_size, and is_valid based on inputs."""
      with tf.compat.v1.name_scope("infer_sizes"):
          if labels is not None:
              if isinstance(labels, dict):
                  labels = next(six.itervalues(labels))
              batch_size, list_size = tf.unstack(tf.shape(input=labels))
              is_valid = utils.is_label_valid(labels)
          else:
              if not example_features:
                  raise ValueError("`example_features` is empty.")
  
              # Infer batch_size and list_size from a feature.
              example_tensor_shape = tf.shape(
                  input=next(six.itervalues(example_features))
              )
              batch_size = example_tensor_shape[0]
              list_size = example_tensor_shape[1]
              # Mark all entries as valid in case we don't have enough information.
              # TODO: Be more smart to infer is_valid.
              is_valid = utils.is_label_valid(
                  tf.ones([batch_size, list_size])
              )
      if batch_size is None or list_size is None:
          raise ValueError(
              "Invalid batch_size=%s or list_size=%s"
              % (batch_size, list_size)
          )
      return batch_size, list_size, is_valid
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import abc
  import six
  import tensorflow
  from tensorflow import estimator
  from tensorflow.python.util import function_utils
  from tensorflow_ranking.python import feature
  from tensorflow_ranking.python import utils
label_desc: Use image node_id 4 for calling a global function with example usage: _infer_sizes(example_features, labels) and returns: batch_size,  list_size,  is_valid