code: def _validate_rank(labels, predictions, weights):
      if weights is not None and len(weights.shape) != len(
          labels.shape
      ):
          raise RuntimeError(
              (
                  "Weight and label tensors were not of the same rank. weights.shape "
                  "was %s, and labels.shape was %s."
              )
              % (predictions.shape, labels.shape)
          )
      if (len(predictions.shape) - 1) != len(labels.shape):
          raise RuntimeError(
              (
                  "Weighted sparse categorical crossentropy expects `labels` to have a "
                  "rank of one less than `predictions`. labels.shape was %s, and "
                  "predictions.shape was %s."
              )
              % (labels.shape, predictions.shape)
          )
  
file_path: autodist/examples/benchmark/utils/modeling/losses/weighted_sparse_categorical_crossentropy.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import tensorflow
label_desc: Use image node_id 2 for calling a global function with example usage: _validate_rank(labels, predictions, weights) without return types