class_docstr: A PTransform to write Metadata to disk.
  
  Input can either be a DatasetMetadata or a tuple of properties.
  
  Depending on the optional `write_to_unique_subdirectory`, writes the given
  metadata to either `path` or a new unique subdirectory under `path`.
  
  Returns a singleton with the path to which the metadata was written.
code: def expand(self, metadata):
      if hasattr(metadata, "deferred_metadata"):
          metadata_pcoll = metadata.deferred_metadata
      else:
          metadata_pcoll = self.pipeline | beam.Create([metadata])
  
      asset_map = getattr(metadata, "asset_map", {})
  
      def write_metadata_output(metadata):
          output_path = self._path
          if self._write_to_unique_subdirectory:
              output_path = common.get_unique_temp_path(self._path)
          metadata_io.write_metadata(metadata, output_path)
          if asset_map:
              with tf.io.gfile.GFile(
                  os.path.join(
                      output_path,
                      output_wrapper.TFTransformOutput.ASSET_MAP,
                  ),
                  "w",
              ) as f:
                  f.write(json.dumps(asset_map))
          return output_path
  
      return metadata_pcoll | "WriteMetadata" >> beam.Map(
          write_metadata_output
      )
  
file_path: transform/tensorflow_transform/beam/tft_beam_io/beam_metadata_io.py
imports: import json
  import os
  import apache_beam
  import tensorflow
  from tensorflow_transform import output_wrapper
  from tensorflow_transform.beam import common
  from tensorflow_transform.tf_metadata import metadata_io
  from tfx_bsl.types import tfx_namedtuple
label_desc: Use image node_id 3 for calling the WriteMetadata obj's underlying member method code with example usage: obj.expand(metadata) and returns: unknown, output_path