code: def _sparse_vs_dense_xent_benchmark_sparse(labels, logits):
      # Using sparse_softmax_cross_entropy_with_logits
      labels = labels.astype(np.int64)
      labels = array_ops.identity(labels)
      logits = array_ops.identity(logits)
      crossent = nn_ops.sparse_softmax_cross_entropy_with_logits(
          logits, labels, name="SequenceLoss/CrossEntropy"
      )
      crossent_sum = math_ops.reduce_sum(crossent)
      grads = gradients_impl.gradients([crossent_sum], [logits])[0]
  
      return (crossent_sum, grads)
  
file_path: tensorflow-upstream/tensorflow/python/kernel_tests/sparse_ops/sparse_xent_op_test.py
imports: import sys
  import time
  from absl import app
  import numpy
  from tensorflow.core.protobuf import config_pb2
  from tensorflow.python.client import session
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import test_util
  from tensorflow.python.kernel_tests.sparse_ops import sparse_xent_op_test_base
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import array_ops_stack
  from tensorflow.python.ops import gradients_impl
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import sparse_ops
  from tensorflow.python.ops.nn_grad import _SparseSoftmaxCrossEntropyWithLogitsGrad
  from tensorflow.python.platform import test
label_desc: Use image node_id 2 for calling a global function with example usage: _sparse_vs_dense_xent_benchmark_sparse(labels, logits) and returns: crossent_sum,  grads