code: def testWriteMetadataDeferred(self):
      # Write metadata to disk using WriteMetadata PTransform, combining
      # incomplete metadata with (deferred) complete metadata.
      expected_asset_map = {"key": "value"}
      with beam.Pipeline() as pipeline:
          path = self.get_temp_dir()
          deferred_metadata = (
              pipeline
              | "CreateDeferredMetadata"
              >> beam.Create([test_metadata.COMPLETE_METADATA])
          )
          metadata = beam_metadata_io.BeamDatasetMetadata(
              test_metadata.INCOMPLETE_METADATA,
              deferred_metadata,
              expected_asset_map,
          )
          _ = metadata | beam_metadata_io.WriteMetadata(path, pipeline)
  
      # Load from disk and check that it is as expected.
      metadata = metadata_io.read_metadata(path)
      self.assertEqual(metadata, test_metadata.COMPLETE_METADATA)
  
      with tf.io.gfile.GFile(
          os.path.join(path, output_wrapper.TFTransformOutput.ASSET_MAP)
      ) as f:
          asset_map = json.loads(f.read())
          self.assertDictEqual(asset_map, expected_asset_map)
  
file_path: transform/tensorflow_transform/beam/tft_beam_io/beam_metadata_io_test.py
imports: import json
  import os
  import apache_beam
  import tensorflow
  from tensorflow_transform import output_wrapper
  from tensorflow_transform.beam.tft_beam_io import beam_metadata_io
  from tensorflow_transform.beam import tft_unit
  from tensorflow_transform.beam.tft_beam_io import test_metadata
  import tensorflow_transform.test_case
  from tensorflow_transform.tf_metadata import metadata_io
label_desc: Use image node_id 2 for calling the BeamMetadataIoTest obj's underlying member method code with example usage: obj.testWriteMetadataDeferred() without return types