class_docstr: Tests for TFRecordObserver class and dataset/spec file functions.
class_docstr_tok: ["Tests","for","TFRecordObserver","class","and","dataset\/spec","file","functions","."]
code: def test_tfrecord_observer(self):
      tfrecord_observer = example_encoding_dataset.TFRecordObserver(
          self.dataset_path, self.simple_data_spec
      )
      # Draw a random sample from the simple spec
      sample = tensor_spec.sample_spec_nest(
          self.simple_data_spec,
          np.random.RandomState(0),
          outer_dims=(1,),
      )
      # Write to file using __call__() function
      for _ in range(3):
          tfrecord_observer(sample)
      # Manually flush
      tfrecord_observer.flush()
      tfrecord_observer.close()
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  import os
  import numpy
  import tensorflow
  from tf_agents.drivers import dynamic_step_driver
  from tf_agents.drivers import py_driver
  from tf_agents.drivers import test_utils
  from tf_agents.drivers import tf_driver
  from tf_agents.environments import tf_py_environment
  from tf_agents.specs import tensor_spec
  from tf_agents.trajectories import trajectory
  from tf_agents.utils import common
  from tf_agents.utils import eager_utils
  from tf_agents.utils import example_encoding_dataset
  from tf_agents.utils import test_utils
label_desc: Use image node_id 2 for calling the TFRecordsUtilsTest obj's underlying member method code with example usage: obj.test_tfrecord_observer() without return types