code: def test_with_one_shot_iterator(synthetic_dataset, reader_factory):
      """Just a bunch of read and compares of all values to the expected values"""
      with reader_factory(synthetic_dataset.url) as reader:
          dataset = make_petastorm_dataset(reader)
          iterator = dataset.make_one_shot_iterator()
  
          # Make sure we have static shape info for all fields
          for shape in dataset.output_shapes:
              # TODO(yevgeni): check that the shapes are actually correct, not just not None
              assert shape.dims is not None
  
          # Read a bunch of entries from the dataset and compare the data to reference
          with tf.Session() as sess:
              iterator = iterator.get_next()
              for _, _ in enumerate(synthetic_dataset.data):
                  actual = sess.run(iterator)._asdict()
                  expected = next(
                      d
                      for d in synthetic_dataset.data
                      if d["id"] == actual["id"]
                  )
                  for key in actual.keys():
                      if isinstance(expected[key], str):
                          # Tensorflow returns all strings as bytes in python3. So we will need to decode it
                          actual_value = actual[key].decode()
                      elif (
                          isinstance(expected[key], np.ndarray)
                          and expected[key].dtype.type == np.unicode_
                      ):
                          actual_value = np.array(
                              [item.decode() for item in actual[key]]
                          )
                      else:
                          actual_value = actual[key]
  
                      np.testing.assert_equal(
                          actual_value, expected[key]
                      )
  
              # Exhausted one full epoch. Fetching next value should trigger OutOfRangeError
              with pytest.raises(tf.errors.OutOfRangeError):
                  sess.run(iterator)
  
file_path: petastorm/petastorm/tests/test_tf_dataset.py
imports: import functools
  import operator
  from copy import copy
  import numpy
  import pytest
  import tensorflow.compat.v1
  from petastorm import make_reader, make_batch_reader
  from petastorm.ngram import NGram
  from petastorm.predicates import in_lambda
  from petastorm.tests.test_common import TestSchema
  from petastorm.tests.test_tf_utils import create_tf_graph
  from petastorm.tf_utils import make_petastorm_dataset
label_desc: Use image node_id 2 for calling a global function with example usage: test_with_one_shot_iterator(synthetic_dataset, reader_factory) without return types