code: def test_compress_image(self):
      if not common.has_eager_been_enabled():
          self.skipTest("Image compression only supported in TF2.x")
  
      gin.parse_config_files_and_bindings(
          [],
          """
      _get_feature_encoder.compress_image=True
      _get_feature_parser.compress_image=True
      """,
      )
      spec = {
          "image": array_spec.ArraySpec((128, 128, 3), np.uint8),
          "mask": array_spec.ArraySpec((128, 128, 1), np.uint8),
      }
      serializer = example_encoding.get_example_serializer(spec)
      decoder = example_encoding.get_example_decoder(spec)
  
      sample = {
          "image": 128 * np.ones([128, 128, 3], dtype=np.uint8),
          "mask": 128 * np.ones([128, 128, 1], dtype=np.uint8),
      }
      example_proto = serializer(sample)
  
      recovered = self.evaluate(decoder(example_proto))
      tf.nest.map_structure(
          np.testing.assert_almost_equal, sample, recovered
      )
  
file_path: agents/tf_agents/utils/example_encoding_test.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from absl.testing import parameterized
  import gin
  import numpy
  import tensorflow
  from tf_agents.specs import array_spec
  from tf_agents.utils import common
  from tf_agents.utils import example_encoding
label_desc: Use image node_id 4 for calling the NestExampleEncodeUtilsTest obj's underlying member method code with example usage: obj.test_compress_image() without return types