code: def test_read_write(self):
      options_data = {
          "instrument_type": "EuropeanOption",
          "strikes": np.array([1.0, 2.0, 3.0], dtype=np.float64),
          "is_call": np.array([True, True, False]),
          "expiries": np.array([0.4, 1.3, 2.3], dtype=np.float64),
      }
      barriers_data = {
          "instrument_type": "BarrierOption",
          "strikes": np.array([1.0, 2.0, 3.0], dtype=np.float64),
          "is_call": np.array([True, True, False]),
          "expiries": np.array([0.4, 1.3, 2.3], dtype=np.float64),
          "barrier": np.array([1.4, 2.5, 2.5], dtype=np.float64),
          "is_knockout": np.array([True, True, False]),
      }
      temp_dir = self.create_tempdir()
      temp_file = path.join(temp_dir.full_path, "datafile.bin")
      with io.ArrayDictWriter(temp_file) as writer:
          writer.write(options_data)
          writer.write(barriers_data)
  
      self.assertTrue(path.exists(temp_file))
  
      # Check that we can read the file.
      reader = io.ArrayDictReader(temp_file)
      first_record = reader.next()
      self.assertEqual(options_data.keys(), first_record.keys())
      for key, value in options_data.items():
          extracted = first_record[key]
          if key == "instrument_type":
              # Strings need to be explicitly coerced to unicode.
              extracted = extracted.astype("U")
          np.testing.assert_array_equal(value, extracted)
  
      remaining = []
      for record in reader:
          remaining.append(record)
  
      self.assertLen(remaining, 1)
      self.assertEqual(barriers_data.keys(), remaining[0].keys())
  
file_path: tf-quant-finance/tf_quant_finance/experimental/io_test.py
imports: from os import path
  from absl.testing import parameterized
  import numpy
  import tensorflow
  from tf_quant_finance.experimental import io
  from tensorflow.python.framework import test_util
label_desc: Use image node_id 3 for calling the IoTest obj's underlying member method code with example usage: obj.test_read_write() without return types