code: def _compare_output_to_expected(
      tester, dict_tensors, expected_tensors, flat_output
  ):
      tester.assertEqual(
          set(dict_tensors.keys()), set(expected_tensors.keys())
      )
  
      i = 0  # Index into the flattened output of session.run()
      for k, v in dict_tensors.items():
          expected_v = expected_tensors[k]
          tf_logging.info("Comparing key: %s", k)
          if isinstance(v, sparse_tensor.SparseTensor):
              # Three outputs for SparseTensor : indices, values, shape.
              tester.assertEqual([k, len(expected_v)], [k, 3])
              tester.assertAllEqual(expected_v[0], flat_output[i])
              tester.assertAllEqual(expected_v[1], flat_output[i + 1])
              tester.assertAllEqual(expected_v[2], flat_output[i + 2])
              i += 3
          else:
              # One output for standard Tensor.
              tester.assertAllEqual(expected_v, flat_output[i])
              i += 1
  
imports: import itertools
  import numpy
  from tensorflow.core.example import example_pb2
  from tensorflow.core.example import feature_pb2
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors_impl
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import sparse_tensor
  from tensorflow.python.framework import tensor_shape
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import parsing_ops
  from tensorflow.python.platform import test
  from tensorflow.python.platform import tf_logging
label_desc: Use image node_id 4 for calling a global function with example usage: _compare_output_to_expected(tester, dict_tensors, expected_tensors, flat_output) without return types