code: def testWriteMetadataIsRetryable(self):
      tft_test_case.skip_if_external_environment(
          "Retries are currently not available on this environment."
      )
      original_write_metadata = (
          beam_metadata_io.metadata_io.write_metadata
      )
      write_metadata_called_list = []
  
      def mock_write_metadata(metadata, path):
          """Mocks metadata_io.write_metadata to fail the first time it is called by this test, thus forcing a retry which should succeed."""
          if not write_metadata_called_list:
              write_metadata_called_list.append(True)
              original_write_metadata(metadata, path)
              raise ArithmeticError("Some error")
          return original_write_metadata(metadata, path)
  
      # Write metadata to disk using WriteMetadata PTransform.
      with mock.patch(
          "tensorflow_transform.tf_metadata.metadata_io.write_metadata",
          mock_write_metadata,
      ):
          with self._makeTestPipeline() as pipeline:
              path = self.get_temp_dir()
              _ = (
                  test_metadata.COMPLETE_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)
  
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 3 for calling the BeamMetadataIoTest obj's underlying member method code with example usage: obj.testWriteMetadataIsRetryable() and returns: original_write_metadata