docstr: Test read access to random offsets in the TFRecord file.
docstr_tok: ["Test","read","access","to","random","offsets","in","the","TFRecord","file","."]
code: def testRandomReaderReadingWorks(self):
      """Test read access to random offsets in the TFRecord file."""
      records = [self._Record(0, i) for i in range(self._num_records)]
      fn = self._WriteRecordsToFile(records, "uncompressed_records")
      reader = tf_record.tf_record_random_reader(fn)
  
      offset = 0
      offsets = [offset]
      # Do a pass of forward reading.
      for i in range(self._num_records):
          record, offset = reader.read(offset)
          self.assertEqual(record, records[i])
          offsets.append(offset)
      # Reading off the bound should lead to error.
      with self.assertRaisesRegex(IndexError, r"Out of range.*offset"):
          reader.read(offset)
      # Do a pass of backward reading.
      for i in range(self._num_records - 1, 0, -1):
          record, offset = reader.read(offsets[i])
          self.assertEqual(offset, offsets[i + 1])
          self.assertEqual(record, records[i])
  
imports: import gzip
  import os
  import random
  import string
  import zlib
  import six
  from tensorflow.python.framework import errors_impl
  from tensorflow.python.lib.io import tf_record
  from tensorflow.python.platform import test
  from tensorflow.python.util import compat
label_desc: Use image node_id 1 for calling the TFRecordRandomReaderTest obj's underlying member method code with example usage: obj.testRandomReaderReadingWorks() without return types