class_docstr: Tests for `migrate_event`.
class_docstr_tok: ["Tests","for","`","migrate_event","`","."]
code: def test_audio(self):
      logdir = self.get_temp_dir()
      steps = (0, 1, 2)
      with test_util.FileWriter(logdir) as writer:
          for step in steps:
              event = event_pb2.Event()
              event.step = step
              event.wall_time = 456.75 * step
              audio = tf.reshape(
                  tf.linspace(0.0, 100.0, 4 * 10 * 2), (4, 10, 2)
              )
              audio_pb = audio_summary.pb(
                  "foo",
                  audio,
                  labels=["one", "two", "three", "four"],
                  sample_rate=44100,
                  display_name="bar",
                  description="baz",
              )
              writer.add_summary(
                  audio_pb.SerializeToString(), global_step=step
              )
      files = os.listdir(logdir)
      self.assertLen(files, 1)
      event_file = os.path.join(logdir, files[0])
      loader = event_file_loader.RawEventFileLoader(event_file)
      input_events = [
          event_pb2.Event.FromString(x) for x in loader.Load()
      ]
  
      new_events = []
      initial_metadata = {}
      for input_event in input_events:
          migrated = self._migrate_event(
              input_event, initial_metadata=initial_metadata
          )
          new_events.extend(migrated)
  
      self.assertLen(new_events, 4)
      self.assertEqual(new_events[0].WhichOneof("what"), "file_version")
      for step in steps:
          with self.subTest("step %d" % step):
              new_event = new_events[step + 1]
              self.assertLen(new_event.summary.value, 1)
              value = new_event.summary.value[0]
              tensor = tensor_util.make_ndarray(value.tensor)
              self.assertEqual(
                  tensor.shape, (3,)
              )  # 4 clipped to max_outputs=3
              self.assertStartsWith(tensor[0], b"RIFF")
              self.assertStartsWith(tensor[1], b"RIFF")
              if step == min(steps):
                  metadata = value.metadata
                  self.assertEqual(
                      metadata.data_class,
                      summary_pb2.DATA_CLASS_BLOB_SEQUENCE,
                  )
                  self.assertEqual(
                      metadata.plugin_data.plugin_name,
                      audio_metadata.PLUGIN_NAME,
                  )
              else:
                  self.assertFalse(value.HasField("metadata"))
  
imports: import os
  import numpy
  import tensorflow
  from tensorboard import dataclass_compat
  from tensorboard.backend.event_processing import event_file_loader
  from tensorboard.compat.proto import event_pb2
  from tensorboard.compat.proto import graph_pb2
  from tensorboard.compat.proto import summary_pb2
  from tensorboard.plugins.audio import metadata
  from tensorboard.plugins.audio import summary
  from tensorboard.plugins.graph import metadata
  from tensorboard.plugins.histogram import metadata
  from tensorboard.plugins.histogram import summary
  from tensorboard.plugins.hparams import metadata
  from tensorboard.plugins.hparams import summary_v2
  from tensorboard.plugins.pr_curve import metadata
  from tensorboard.plugins.pr_curve import summary
  from tensorboard.plugins.scalar import metadata
  from tensorboard.plugins.scalar import summary
  from tensorboard.util import tensor_util
  from tensorboard.util import test_util
label_desc: Use image node_id 8 for calling the MigrateEventTest obj's underlying member method code with example usage: obj.test_audio() without return types